I'm trying to understand why this and prototype behave differently in the constructor vs. the new instance. In the following code Aircraft.range returns undefined. I can't understand why it doesn't return 2,000 like the new instance.
function Aircraft() {
this.range = '2,000 Km';
}
let mustang = new Aircraft();
console.log('Aircraft.range ', Aircraft.range);
console.log('mustang.range ', mustang.range);
This attempt using prototype produces the same result.
function Aircraft() {}
Aircraft.prototype.range = '2,000 Km';
let mustang = new Aircraft();
console.log(Aircraft.range);
console.log(mustang.range);
**** Update ****
I've read many articles on prototypes and instances but theory only goes so far. This is a specific question used to work out the mechanics of these ideas. The answers I received helped me understand this concept better than a dozen articles talking about theory. I'm sure that these answers will help other people trying to learn the fundamentals of Javascript.