How does the greet method become available to the john instance?
function Person(name) {
this.name = name;
}
Person.prototype.greet = function() {
return `Hello, I'm ${this.name}`;
};
const john = new Person('John');
The greet method is available through john's prototype chain: 1) When john is created with new Person(), it gets linked to Person.prototype, 2) john doesn't have its own greet method, so JS looks up the prototype chain, 3) It finds greet in Person.prototype and executes it with john as this context, 4) This prototype lookup is automatic and transparent to the caller, 5) This mechanism enables efficient memory usage by sharing methods across instances, 6) The prototype chain continues until null is reached if properties aren't found.