Questions
8 of 32
1What is the constructor function?
2What are Objects?
3What are the properties of an object?
4How does javascript implements object oriented programming?
5What are the key differences between javascript’s Object-based Inheritance and Conventional Class-based Inheritance?
6What is a prototype in JavaScript?
7How we can implement prototype-based inheritance?
8Explain the prototype chain and its role in property lookup.
9What is the difference between an object's `__proto__` and a constructor function's `prototype` property and [[Prototype]]?
10What are object wrappers for primitive type?
11Can you explain the use of object wrappers with examples?
12Explain how the `instanceof` operator works.
13What are different methods to create an object?
14What is an object initializer?
15What does the `Object.create()` method do?
16How are constructor functions used to create objects with shared properties and methods?
17Show an example of ES6 classes to create objects and inherit properties?
18What are factory functions in JavaScript ?
19What are Object constructors in JavaScript ?
20How can you add new properties and methods to the prototype of an existing constructor function?
21What is prototype pollution, and how can it be a security risk in JavaScript?
22Is modifying or extending built-in object prototypes recommended (e.g., adding a method to `Array.prototype`)? Why or why not?
23What happens when you try to access a property that doesn't exist on an object?
24How can you prevent or mitigate prototype pollution vulnerabilities in your code?
25How does the `Object.prototype.hasOwnProperty()` method work?
26How can you optimize prototype chain lookup for better performance?
27Can you explain how `Object.prototype.constructor` property works?
28What is the difference between modifying the prototype of an object and adding a property directly to the object?
29How does JavaScript handle circular references in object prototypes?
30What is static dispatching in object-oriented programming?
31What is the purpose of the `Object.keys()` method?
32Write a function flattenObject(obj) that flattens a deeply nested object into a single-level object, using dot notation for nested keys.
08 / 32

Explain the prototype chain and its role in property lookup.

Objects can inherit properties and methods from their prototypes through a process called the prototype chain. The prototype chain is a series of linked objects that are used for property and method lookup. When you try to access a property on an object, JavaScript first checks if the property exists on the object itself. If not, it looks at the object's prototype a the object referenced by its [[Prototype]] property. This process continues up the chain until the property is found or until the chain reaches the global Object.prototype object, which is the ultimate ancestor of all objects.

Difficulty: 5/10
Topics: prototype chain, property lookup, inheritance

Scenario Questions

0-2 years experience
  1. 1

    You have let car = { wheels: 4 }; car.__proto__ = { drive() { return 'vroom'; } }; what does car.drive()` return and why?

  2. 2

    If you define function Person(){} and then set Person.prototype.age = 30;, what happens when you do new Person().age? Walk me through the lookup.

  3. 3

    Suppose you delete a property that exists only on an object's prototype. What will a subsequent access to that property on the instance return?

2-5 years experience
  1. 1

    Your team added a method to Array.prototype and now some pages crash with ‘undefined is not a function’ when calling arr.map. How would you investigate whether prototype pollution is the cause?

  2. 2

    A bug shows obj.foo as undefined even though you see foo defined on a parent object. What could be wrong with the prototype chain and how would you debug it?

  3. 3

    We refactored a class hierarchy to ES6 class syntax, but an inherited method disappeared. Explain how the prototype chain might have changed and how to restore the behavior.

5-8 years experience
  1. 1

    Our UI library uses a base component prototype that many widgets inherit from, and we’re seeing higher memory usage and slower property access. How would you assess the trade‑offs of prototype inheritance versus composition or class fields?

  2. 2

    We need a plugin system where plugins can extend core objects at runtime. Design a prototype‑based extension strategy that is safe for existing code and describe the safeguards you’d put in place.

  3. 3

    During a performance audit, deep prototype chains are causing latency in hot loops. What techniques would you use to flatten or cache lookups, and what risks do those techniques carry?

8+ years experience
  1. 1

    Our legacy codebase heavily mutates prototypes, and we’re migrating to a strict TypeScript codebase with classes. Outline a migration plan that preserves behavior, handles prototype differences, and minimizes cross‑team risk.

  2. 2

    We’re building a shared data model that must expose a stable API yet allow per‑team extensions. How would you structure the prototype chain—or choose an alternative pattern—to balance extensibility, type safety, and versioning?

  3. 3

    Discuss the long‑term maintenance implications of exposing prototype augmentation in a library used by many downstream services, and propose policies or tooling to manage it safely.

Follow-up Questions

  • What steps does the engine take when a property isn’t found on the object itself?
  • How would you verify that a prototype change behaved as expected?
  • What performance concerns arise from very deep prototype chains?