"Explain prototypes" filters senior-track candidates. The mental model is one sentence: when a property isn't on an object, JavaScript looks up a chain of linked objects until it finds it or runs out.
Seeing the chain
const arr = [1, 2, 3]; arr.push(4); // arr has no "push" โ found on Array.prototype // chain: arr โ Array.prototype โ Object.prototype โ null arr.toString(); // found two hops up, on Object.prototype... // (actually Array.prototype overrides it โ closest wins!)
class is prototype sugar
class Student {
constructor(name) { this.name = name; }
greet() { return `Hi ${this.name}`; }
}
// is (almost) exactly:
function Student(name) { this.name = name; }
Student.prototype.greet = function () { return `Hi ${this.name}`; };
// greet lives ONCE on the prototype โ 1000 students share it (memory win)The naming confusion, resolved
Student.prototypeโ the object instances will link tostudent.__proto__(officiallyObject.getPrototypeOf) โ the actual link on an instanceextendschains prototypes: instance โ Topper.prototype โ Student.prototype โ Object.prototype
Interview payoffs: explains why editing Array.prototype is dangerous, how polyfills work, and what hasOwnProperty actually checks.