JavaScript (ES2026) reference · Object Methods
JavaScript Object.create() Method
Create a new object with the given prototype (or null for an object with no inherited properties at all).
JavaScript (ES2026) Since ES5
Syntax
Object.create(proto, propertiesObject)
Parameters
| Parameter | Description |
|---|---|
proto |
The prototype for the new object, or null. |
propertiesObject optional |
Property descriptors to add. |
Return value
A new object.
Examples
const animal = { speak() { return `${this.name} makes a sound`; } };
const dog = Object.create(animal);
dog.name = "Rex";
console.log(dog.speak(), Object.getPrototypeOf(dog) === animal);
Output
Rex makes a sound true
const dict = Object.create(null);
dict.toString = "just data";
console.log("hasOwnProperty" in dict, dict.toString);
Output
false just data
Version history
| Version | Change |
|---|---|
| JavaScript ES5 | Added |
Related
Object.getPrototypeOf()· Return the prototype of an object: the object it inherits methods and properties from, or null.Object.setPrototypeOf()· Change the prototype of an existing object. It is slow in most engines; prefer Object.create() or classes.- JavaScript Objects · tutorial