__proto__ was originally hacked only for Mozilla in earlier versions of Mozilla browsers (Firefox prior to 3.5). It was codified in ECMAScript 3.1 only in 2008.
One of the differences is that __proto__ can be changed (for example, poor design), and getPrototypeOf is a read function.
var parentObject = {"parentKey" : "parentValue"}; var childObject = {"childKey" : "childValue"}; childObject.__proto__ = parentObject; console.log(childObject.parentKey); // parentValue Object.getPrototypeOf(childObject) = {"parentKey" : "newValue"}; // ReferenceError: Invalid left-hand side in assignment
Another difference is how they handle the unlikely event of a name conflict:
var myObject = { __proto__ : "conflicts", getPrototypeOf : function () {return "does not conflict"} }; console.log( myObject.getPrototypeOf() ); // "does not conflict" // all objects inherit from Object.prototype, not Object, so there is no conflict console.log( Object.getPrototypeOf(myObject) ) // Object {} console.log( myObject.__proto__ ); // Object {}, the value "conflicts" is lost
source share