Questions
2 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.
02 / 32

What are Objects?

In JavaScript, objects are one of the most fundamental and versatile data types. They are collections of key-value pairs, where the keys (also called properties) are strings or symbols, and the values can be of any data type, including other objects, functions, or arrays.

  1. 1

    Prototypal Inheritance: Objects can inherit properties and methods from other objects using prototypes.

  2. 2

    Dynamic Structure: Objects can have properties added or removed dynamically.

  3. 3

    Flexibility: They can store mixed data types and methods (functions that belong to the object).

Difficulty: 3/10
Topics: object literals, prototypes, property descriptors

Scenario Questions

0-2 years experience
  1. 1

    You need to store a user's name, email, and a list of their favorite colors. Show me how you'd create that object and then add a new favorite color later.

  2. 2

    What happens if you try to read a property that doesn't exist on an object — say, user.age when age was never set? What if you then assign to it?

  3. 3

    Write a function that takes an object and a key, and returns true only if that key exists directly on the object (not inherited). How would you check that?

2-5 years experience
  1. 1

    A teammate passes an object method as a callback to setTimeout, but inside the callback this is undefined. Why does that happen, and how would you fix it without changing the call site?

  2. 2

    You're debugging a performance issue where a hot loop creates thousands of similar objects. What properties of object creation could you optimize, and how would you measure the impact?

  3. 3

    Explain the difference between shallow and deep cloning an object. Give a real example where a shallow copy caused a bug in your codebase.

5-8 years experience
  1. 1

    We're building a high-frequency trading module where every microsecond counts. How would you design the order object to minimize GC pressure and maximize property access speed? Mention hidden classes or inline caches if relevant.

  2. 2

    A legacy codebase uses deep prototype chains for domain models. You've been asked to refactor toward composition. Walk me through the risks of the current hierarchy and how you'd migrate incrementally without breaking downstream consumers.

  3. 3

    When would you choose Object.defineProperty with configurable:false over a TypeScript readonly modifier? What runtime guarantees does each actually give you?

8+ years experience
  1. 1

    Three teams own services that share a 'User' object shape across RPC boundaries. One team wants to add a nullable field, another wants to rename a key, and a third needs a new nested object. How do you govern this evolution without versioning hell?

  2. 2

    We're migrating a 10-year-old prototype-heavy codebase to modern classes. The prototype chain includes circular references and dynamic property additions. What's your migration strategy, and how do you verify behavioral parity?

  3. 3

    An internal library exposes a configuration object that consumers mutate directly, causing subtle bugs across repos. Propose an API design that prevents mutation while staying ergonomic for feature teams. How do you roll it out?

Follow-up Questions

  • How does property lookup work when a key isn't found on the object itself?
  • What's the difference between Object.create(null) and {}?
  • When would you use a Map instead of a plain object?