Like everything it is deeper than that, I had a cooler response typed up but someone else said it better
"So proto is the actual object that is saved and used as the prototype while Myconstructure.prototype is just a blueprint for proto which, is infact the actual object saved and used as the protoype. Hence myobject.prototype wouldnt be a property of the actual object because its just a temporary thing used by the constructor function to outline what myobject.proto should look like."
While the actual object prototype link is an internal property, i.e. it's implementation dependent to allow for optimization, Firefox's JavaScript engine SpiderMonkey exposed it with __proto__ which was soon copied by other browsers.
ES2015:
1.) deprecates __proto__
2.) turned __proto__ into a getter/setter.
What's the difference between
.__proto__
and.prototype
?Like everything it is deeper than that, I had a cooler response typed up but someone else said it better
"So proto is the actual object that is saved and used as the prototype while Myconstructure.prototype is just a blueprint for proto which, is infact the actual object saved and used as the protoype. Hence myobject.prototype wouldnt be a property of the actual object because its just a temporary thing used by the constructor function to outline what myobject.proto should look like."
(stackoverflow.com/questions/995972...)
You don't want to use ".proto" in the real world.
(developer.mozilla.org/en-US/docs/W...)
It was easy to use to make this to prove a point.
prototype
is the property you set on a constructor function - any objects created vianew
will have that object as their prototype.While the actual object prototype link is an internal property, i.e. it's implementation dependent to allow for optimization, Firefox's JavaScript engine SpiderMonkey exposed it with
__proto__
which was soon copied by other browsers.ES2015:
1.) deprecates
__proto__
2.) turned
__proto__
into a getter/setter.__proto__ in ECMAScript 6
Now if you want to get the prototype of an object use Object.getPrototypeOf() and you can create an object with a prototype with Object.create()
JavaScript's prototypal inheritance is based on Self.