JavaScript·Intermediate·Coding·1 min read
How are constructor.prototype and an instance's prototype related?
Short interview answer
When a constructable function is called with new, the new object's [[Prototype]] is normally set to the constructor's prototype property. The prototype property itself is just an ordinary property on the constructor function; it is not the constructor's own prototype.
Example
function Point(x) { this.x = x; }Point.prototype.describe = function () { return `x=${this.x}`; };
const p = new Point(3);Object.getPrototypeOf(p) === Point.prototype; // truep.describe(); // "x=3" (via the chain)Key takeaway
Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.