The difference between proto-link and Object.create

I want to know the difference between __proto__and methods Object.create. Take this example:

var ob1 = {a:1};
var ob2 = Object.create(ob1);

ob2.__proto__ === ob1; // TRUE

This means that the Object.create method creates a new object and establishes a reference __proto__to the object received as a parameter. Why don't we use the link directly __proto__instead of the create method?

+5
source share
2 answers

__proto__non-standard and not supported everywhere. Object.createis part of the official specification and should be supported by every future environment.

It is also implemented differently in different places.

From Effective Javascript :

, , . __proto__ Object.prototype, __proto__

- Object.create, , Object.getPrototypeOf.

+3

create?

__proto__ .

ES.next. : MDN - __proto__.

+3

All Articles