![]() |
VOOZH | about |
JavaScript object.create() method is used to create a new object with the specified prototype object and properties. Object.create() method returns a new object with the specified prototype object and properties.
Object.create(prototype[, propertiesObject])Examples 1: In this example, there are two functions "fruits" and "apple".A new instance of apple is created which is named as "app" and it has been specified with the prototype and property of "fruits" i.e. this.name = 'fruit 1'.
Output:
"fruit 1"Example 2: In this example, there are two functions "fruits" and "apple".A new instance of apple is created which is named "app" and it has been specified with the prototype and property of "fruits" i.e. this.name = 'fruit 1' and this .season = 'summer'.
Output:
"fruit 1"
"summer"
We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.