DEV Community

Marc West
Marc West

Posted on

Object.create()

The Object.create() Method

Object.create is a newer method in JavaScript that can be a more simple and efficient way for you to create objects. Although there are many ways to accomplish making new objects and assigning them properties, the Object.create method is unique because it lets you bypass making a constructor function by allowing you to set any existing object as the prototype for a new object.

This method takes two parameters: the first being the object being used as the prototype, and the second an optional properties object which is used to set specific properties on the new object. When the new object is returned it will have all the properties of its prototype plus its own properties, either given through the properties object or added later with dot or bracket notation.

in conclusion, Object.create is a quick and easy way to create new objects. With the seemingly endless ways to make new objects, Object.create simplifies the process. Even with its awkward optional second parameter, it is an easy way for programmers, especially newcomers like myself, to create new objects and keep track of their inheritance.

Top comments (0)