Prototype Chain & new
JavaScript Closures
Why This Is Asked
This separates developers who have surface-level ES6 class knowledge from those who understand JavaScript’s true inheritance model. Interviewers want to see if you can explain what new actually does under the hood and how the prototype chain resolves property lookups.
Key Concepts
- JavaScript uses prototypal inheritance, not classical inheritance — objects inherit directly from other objects
- Every object has a hidden
[[Prototype]]link; property lookups walk this chain untilnull newdoes four things: creates an empty object, links its prototype, executes the constructor withthisbound, returns the object (unless the constructor returns a different object)__proto__is the object’s prototype link;.prototypeis a property on functions used when they act as constructorsclasssyntax is syntactic sugar — it does not change the underlying prototype mechanism