When is __proto__
useful?
A lot of browsers support it, but because not all do, programmers seem to be scared of using it. I've never seen it in any code (such as the libraries jQuery and backbone.js).
When is __proto__
useful? Is it just a geeky thing for completeness?
Description. The __proto__ getter function exposes the value of the internal [[Prototype]] of an object. For objects created using an object literal, this value is Object.
__proto__ is a way to inherit properties from an object in JavaScript. __proto__ a property of Object. prototype is an accessor property that exposes the [[Prototype]] of the object through which it is accessed. POSTly is a web-based API tool that allows for fast testing of your APIs (REST, GraphQL).
You should use prototypes if you wish to declare a "non-static" method of the object. var myObject = function () { }; myObject. prototype.
Prototypical inheritance allows us to reuse the properties or methods from one JavaScript object to another through a reference pointer function.
__proto__
is deprecated and should not be used. Use Object.getPrototypeOf
instead. See https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/Proto - But Opera supports __proto__
and not Object.getPrototypeOf
, so beware.
That said, Object.getPrototypeOf
is, like the name says, used to get the prototype of an object. I've never found this useful yet.
Edit 2012-02-06 Opera supports Object.getPrototypeOf
as of 11.60
.
It is useful if you are going to modify an objects prototype and need to find out if it has been already modified.
Note that __proto__
is deprecated, instead you should is Object.getPrototypeOf
.
MDN Documentation on proto
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With