Facebook Pixel

What is at the end of the prototype chain in JavaScript?

null. Object.prototype is the root of most prototype chains. Object.getPrototypeOf(Object.prototype) returns null. This is how JS knows to stop the lookup.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in The Prototype Chain: How Property Lookup Works

Check the object itself, then its prototype (__proto__), then the prototype's prototype, up to null. If the property is found, return it. If not found, return undefined.

A method that checks if a property is the object's own (not inherited from the prototype chain). dog.hasOwnProperty('name') is true (own). dog.hasOwnProperty('legs') is false (inherited from animal).

JavaScript returns undefined. It does not throw an error. The lookup traverses the entire chain (obj -> proto -> proto.proto -> ... -> null) and if the property is not found anywhere, returns undefined.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0