Instance Properties: Where They Live
In this lesson, you'll learn where instance properties are actually stored and why they don't live on the prototype.
The Key Location Question
When you define properties inside a class's constructor method using this.propertyName = value, those properties are created directly on each individual instance object, not on the class's prototype.
This is a crucial distinction: instance properties are unique to each object you create with new. If you create three instances, each gets its own separate copy of those properties with potentially different values.
Where They Actually Live
class Dog {
constructor(name, age) {
this.name = name; // Lives on the instance
this.age = age; // Lives on the instance
}
}
const buddy = new Dog('Buddy', 3);
const max = new Dog('Max', 5);
console.log(buddy.name); // 'Buddy' - stored on buddy
console.log(max.name); // 'Max' - stored on max
Each dog has its own name and age stored directly on itself. When you access buddy.name, JavaScript finds it immediately on the buddy object—it doesn't need to look up the prototype chain.
Why Not the Prototype?
The prototype is for shared behavior (methods), not unique data. If properties lived on the prototype, all instances would share the same values, which defeats the purpose of having multiple distinct objects.
console.log(buddy.hasOwnProperty('name')); // true
console.log(Dog.prototype.hasOwnProperty('name')); // false
Key Takeaway: Instance properties defined in the constructor live directly on each instance object, giving each object its own unique data separate from the shared prototype.