JAVASCRIPT GUIDE

JavaScript Prototypes and Inheritance

By the HireReadyAI team · 8 min read

Prototype chains, class sugar, own vs inherited properties, and whiteboard tips.

Prototype chain

Objects can delegate property lookup to another object via [[Prototype]]. When you read obj.x, the engine walks the chain until it finds x or reaches null. This underpins inheritance in JavaScript.

Classes and prototypes

class syntax is sugar over prototypes. Methods land on the prototype; instance fields live on the instance. Understanding this helps debug “shared vs per-instance” behavior.

Own vs inherited

hasOwnProperty / Object.hasOwn distinguish own keys from inherited ones. for...in enumerates enumerable inherited keys — often surprising. Prefer Object.keys for own enumerable keys.

Interview tips

Draw a tiny chain on the whiteboard: instance → ctor.prototype → Object.prototype → null. Then explain __proto__ vs prototype (instance link vs function’s prototype object).

All guides · HireReadyAI home

Practice this topic in a mock interview