JavaScript Object.create()
Example
// Create an Object:
const person = {
firstName: "John",
lastName: "Doe"
};
// Create new Object
const man = Object.create(person);
man.firstName = "Peter";
Try it Yourself »
Description
The Object.create()
creates an object from an existing object.
Related Methods:
Object.assign() copies properties from a source object to a target object.
Object.create() creates an object from an existing object.
Object.fromEntries() creates an object from a list of keys/values.
Syntax
Object.create(object, properties)
Parameters
Parameter | Description |
object | Required. An existing object. |
properties | Optional. A descriptor of properties to be added or changed: value: value writable : true|false enumerable : true|false configurable : true|false get : function set : function |
Return Value
Type | Description |
Object | The created object. |
Browser Support
Object.create()
is an ECMAScript5 (ES5) feature.
ES5 (JavaScript 2009) is fully supported in all modern browsers since July 2013:
Chrome 23 |
IE/Edge 11 |
Firefox 21 |
Safari 6 |
Opera 15 |
Sep 2012 | Sep 2012 | Apr 2013 | Jul 2012 | Jul 2013 |