JavaScript Object.create()
- Previous page constructor
- Next page defineProperties()
- Go back to the previous level JavaScript Object Reference Manual
Definition and usage
Object.create()
Methods used to create a new object from an existing object.
Related methods:
Object.assign()
Copy the properties of the source object to the target object.
Object.create()
Create a new object from an existing object.
Object.fromEntries()
Create an object from a list of key/value pairs.
Instance
// Create an object const person = { firstName: "Bill", lastName: "Gates" }; // Create a new object const man = Object.create(person); man.firstName = "Peter";
Syntax
Object.create(object, properties)
Parameter
Parameter | Description |
---|---|
object | Required. Existing object. |
properties |
Optional. The property descriptor to add or modify:
|
Return value
Type | Description |
---|---|
Object | The newly created object. |
Browser support
Object.create()
Is a feature of ECMAScript5 (ES5).
Since July 2013, all modern browsers fully support ES5 (JavaScript 2009):
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome 23 | IE/Edge 11 | Firefox 21 | Safari 6 | Opera 15 |
September 2012 | September 2012 | April 2013 | July 2012 | July 2013 |
- Previous page constructor
- Next page defineProperties()
- Go back to the previous level JavaScript Object Reference Manual