Object.create()

Creates a new object with the specified prototype and optional properties.

Since ES5 Spec ↗

Syntax

Object.create(proto, propertiesObject)

Parameters

NameTypeRequiredDescription
proto object | null Yes The prototype for the new object, or null for no prototype.
propertiesObject object No Property descriptors to define on the new object (same format as Object.defineProperties).

Returns

object — A new object with the given prototype and properties.

Throws

  • TypeError — proto is neither an object nor null.

Examples

const proto = { greet() { return 'hi'; } };
const o = Object.create(proto);
console.log(o.greet());
Output
hi
const dict = Object.create(null);
console.log(Object.getPrototypeOf(dict));
Output
null

Notes

`Object.create(null)` makes a prototype-less object - a safe map without inherited keys like `toString`. Combine with descriptors for fine-grained property control.

Browser & runtime support

EnvironmentSince version
chrome 5
firefox 4
safari 5
edge 12
node 0.10

See also