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

What are different methods to create an object?

Difficulty: 5/10
object literals, constructor functions, Object.create

Object Literal, Object.create() method, Constructor function, ES6 class, Factory functions, Object() Constructor

  1. 1

    Object initializer/Object Literal: Const newObject={a:1, b:5}

  2. 2

    Object.create(): Object.create(proto, propertiesObject)

  3. 3

    Constructor function

  4. 4

    ES6 class

  5. 5

    Factory functions

  6. 6

    Object() Constructor/ Type Transformer: new Object(value)

Scenario Questions

0-2 years experience

  1. 1How would you create a simple user settings object using an object literal?
  2. 2If you need to create many similar product objects, which creation method would you pick and why?
  3. 3What happens if you try to use the new operator with an object literal?

2-5 years experience

  1. 1We have a widget constructor that seems to be leaking memory; how would you debug the object creation pattern?
  2. 2Explain why using Object.create to set up a prototype chain can break when methods are later added to the prototype.
  3. 3Given a feature that must serialize objects to JSON, which creation technique would you choose and why?

5-8 years experience

  1. 1Design a factory module that can produce different chart objects; discuss trade‑offs between ES6 classes and Object.create.
  2. 2How would you refactor a legacy codebase that uses constructor functions into modern class syntax without breaking existing consumers?
  3. 3In a high‑traffic real‑time app that creates thousands of temporary objects per second, which object‑creation pattern would you use to minimise GC pressure and why?

8+ years experience

  1. 1Our platform must support plugins written in both ES5 and ES6. How would you design a unified object‑creation strategy that eases migration?
  2. 2Discuss the long‑term maintenance implications of mixing multiple object‑creation patterns in a large codebase and propose a policy.
  3. 3If you were to introduce a code‑generation tool that emits object‑creation code, what patterns would you enforce to ensure consistency and performance at scale?

Follow-up Questions

  • Can you show a quick code example?
  • What edge cases might cause bugs with that approach?
  • How would you test that your objects behave correctly?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.