Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Class

Object

Object is JavaScript’s general-purpose object type for keyed collections and complex entities. Objects are commonly created with literals and usually inherit from Object.prototype.

How it works

Object is JavaScript’s general-purpose object type. Use object literals for ordinary records, or call Object with a value when you specifically need its conversion behavior; objects normally inherit from Object.prototype unless their prototype is null or comes from another null-prototype object.

Syntax

Object(value)

Parameters

NameTypeDescription
valueanyThe optional value to convert into an object; null and undefined produce an empty object, existing objects are returned, and other values produce corresponding wrapper objects.

Returns

An object representing the input; for null or undefined, an empty object; for an existing object, the same object.

Key points

  • Object is a built-in JavaScript data type for general-purpose objects.
  • Use objects to represent keyed records and structures whose properties can model richer entities.
  • The two fundamental creation forms are Object() and object-literal syntax.
  • Most JavaScript objects are Object instances, including ordinary objects created with literals.
  • Ordinary objects receive inherited properties and methods through Object.prototype.
  • Objects with a null prototype are the principal exception to normal Object.prototype inheritance.

Common mistakes

  • Modifying Object.prototype can affect every object that inherits from it, so avoid treating it as private shared state.
  • A null-prototype object does not provide the usual inherited Object methods.

Example: Create a null-prototype object

const settings = Object.create(null);
settings.theme = "dark";

console.log(settings.theme);
console.log(Object.getPrototypeOf(settings));

Creates a dictionary-like object without inherited prototype properties, then reads its own data.

When to use it

Keyed records

Represent named application data such as configuration, records, or grouped state.

Prototype-free dictionaries

Use a prototype-free dictionary when inherited properties should not participate in lookup.

Complex entities

Model richer entities by combining properties, methods, and prototype-based behavior.

Interview questions

QWhat is Object used for, and what is its usual prototype relationship?

Object is the built-in type used for keyed collections and more complex entities. Most objects inherit properties and methods from Object.prototype, unless they have a null prototype or descend from one.

Follow-up: How can you create an object without that inheritance? Use Object.create(null), producing a null-prototype object.

QHow can JavaScript objects be created?

An object can be created with the Object() constructor or with object-literal syntax. Object literals are generally the concise choice for initializing ordinary records.

Follow-up: What alternative lets you choose the prototype? Object.create() allows the prototype object to be selected directly.

QWhat does calling Object() do with different inputs?

Object() turns its input into an object. With null or undefined it creates an empty object; an existing object is returned unchanged; other values produce an object corresponding to that value’s type.

Follow-up: Why might Object(value) differ from a literal? It performs conversion and may create a wrapper object for a primitive, whereas a literal creates a plain object.

  • Object.create()
  • Object.assign()
  • Object.getOwnPropertyNames()
  • Object.prototype

Source: Object. Checked 2026-10-15.