JavaScript · Middle · Question 6 of 75
How does the engine look up a property the object itself doesn't have?
- ✓Correct answer: It walks up the prototype chain until it finds the property or reaches
null - 2It immediately returns
undefinedwithout looking into any other objects - 3It looks for a variable with that name in the outer scopes
Explanation
Every object has a hidden [[Prototype]] link (Object.getPrototypeOf). That's how arrays get map from Array.prototype and all objects get toString from Object.prototype. Scope lookup applies to variables, not properties.