Skip to content
Advertisement

Tag: object-create

What is difference between creating object using Object.create() and Object.assign()?

Considering following code: Is there any difference between obj1 and obj2 since each object has been created in a different way? Answer Let’s compare obj1 and obj2 in this code: Prototypical chain Object.create creates a new object with the specified [[Prototype]], and Object.assign assigns the properties directly on the specified object: The prototypical chains of obj1 and obj2 look like

Advertisement