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

JavaScript · Function

Object.create

Object.create() creates a new object with a chosen prototype. An optional descriptor map defines its own properties with precise attribute control.

How it works

Object.create() makes a new object whose internal prototype is the supplied object or null. Its optional second argument defines own properties through descriptor objects, giving precise control over attributes such as writability, enumerability, and configurability.

Syntax

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

Parameters

NameTypeDescription
protoobject or nullThe object that becomes the prototype of the newly created object; it may also be null.
propertiesObjectobject or undefinedOptional object whose enumerable own properties provide property descriptors for the new object's own properties.

Returns

A new object with the specified prototype and properties.

Key points

  • It creates a fresh object linked to the supplied prototype.
  • The one-argument form accepts the prototype directly.
  • A second argument can define own properties during creation.
  • The descriptor source is read from the second argument's enumerable own properties.
  • The property-definition behavior follows Object.defineProperties() descriptor conventions.
  • The return value contains both the selected prototype relationship and the defined own properties.

Common mistakes

  • Descriptors in propertiesObject default to non-writable, non-enumerable, and non-configurable when those attributes are omitted.
  • The first argument must be null or an object; otherwise the call throws a TypeError.
  • Object.create() is not generally required for ordinary object literals, which provide a concise equivalent for common initialization patterns.

Example: Create an object with a prototype and a descriptor

const prototype = {
  greet() {
    return `Hello, ${this.name}`;
  },
};

const person = Object.create(prototype, {
  name: {
    value: "Ada",
    writable: true,
    enumerable: true,
    configurable: true,
  },
});

console.log(person.greet()); // Hello, Ada
console.log(Object.getPrototypeOf(person) === prototype); // true

The new object inherits greet from prototype, while name is defined through a property descriptor.

When to use it

Prototype-based delegation

Build objects that delegate behavior or data lookup to a shared prototype object.

Null-prototype records

Create dictionary-like objects without inherited Object.prototype properties.

Descriptor-controlled initialization

Define several own properties with explicit writability, enumerability, or configurability settings at creation time.

Interview questions

QWhat does Object.create() do?

It returns a new object whose prototype is proto. The optional propertiesObject argument defines own properties using property descriptors rather than assigning ordinary values.

Follow-up: What happens with Object.create(null)? It creates an object whose prototype is null, so it does not inherit methods such as those from Object.prototype.

QWhat values are valid for the first argument?

proto must be either an object or null. Passing another value causes a TypeError.

Follow-up: How can a caller avoid that exception? Validate that the prototype is null or an object before calling Object.create().

QHow does the second argument define properties?

Each enumerable own property of propertiesObject describes a property to add to the new object. Descriptor fields control attributes such as value, writable, enumerable, and configurable.

Follow-up: What is the default for omitted descriptor attributes? They are false, so the resulting property is not writable, enumerable, or configurable unless enabled explicitly.

  • Object.defineProperties()
  • Object.getPrototypeOf()
  • Object.prototype
  • __proto__
  • new

Source: Object.create(). Checked 2026-10-15.