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

What do the built in Object constructors do in JavaScript ?

Difficulty: 4/10
constructor functions, prototype chain, class syntax

They can be used to create new objects or as Type Transformer.

The Object() constructor turns the input into an object. Its behavior depends on the input's type.
  1. 1

    If the value is null or undefined, it creates and returns an empty object.

  2. 2

    If the value is an object already, it returns the value.

  3. 3

    Otherwise, it returns an object of a type that corresponds to the given value. For example, passing a BigInt primitive returns a BigInt wrapper object

javascript
Ensuring an Input is Object-Safe: If you are writing a function that expects an object but might receive null, calling Object() on the input prevents your code from crashing when you try to access properties.
Coercing Primitives to Objects: Sometimes you need a primitive to behave like an object permanently (not just via temporary autoboxing).
Checking if a value is already an object: Since Object(value) returns the same reference if the input is already an object, you can use it for identity checks.

Scenario Questions

Share

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