Do __proto__ and Object.getPrototype of expose exactly the same functionality?
Do
__proto__
andObject.getPrototype
of expose exactly the same functionality?
No. .__proto__
only works on objects that inherit from Object.prototype
. And Object.getPrototype
doesn't allow to mutate the prototype.
Does the standardization of
__proto__
in ES2015 negate the need forObject.getPrototypeOf
?
You've got it backwards. ES5 Object.getPrototypeOf
and ES6 Object.setPrototypeOf
completely negate the need to ever use __proto__
.
The Object.prototype.__proto__
accessor property is only standardised in ES6 for backwards compatibility and interoperability between implementations that need it. It's explictly marked as a web legacy feature. Check the note on Annex B ("…legacy features [for] web browser based ECMAScript implementations. [They] have […] undesirable characteristics and […] would be removed from this specification [if not used] by large numbers of existing web pages […]. Programmers should not use or assume the existence of [them] when writing new ECMAScript code. ECMAScript implementations are discouraged from implementing these features.")