属性“__ proto_”被储存了? [英] Where the property "__proto_" is stored?
问题描述
告诉我属性__proto_存储在哪里?
Tell me where the property "__proto_" is stored ?
推荐答案
它继承自 Object.prototype
:
({}).hasOwnProperty('__proto__') // false
Object.prototype.hasOwnProperty('__proto__') // true
根据 MDN文章,
__ proto __
属性没有什么特别之处。它只是
一个访问者属性 - 一个由getter函数和
a setter函数组成的属性 - 在 Object.prototype 。__ proto __
的属性访问,最终咨询 Object.prototype 将找到这个
属性,但访问不参考 Object.prototype
找不到它。如果在
__ proto __ 属性查询了JavaScript / Reference / Global_Objects / Object / prototyperel =nofollow> Object.prototype ,该属性将隐藏 .org / zh-CN / docs / Web / JavaScript / Reference / Global_Objects / Object / prototyperel =nofollow> Object.prototype 。
There is nothing special about the
__proto__
property. It is simply an accessor property -- a property consisting of a getter function and a setter function -- on Object.prototype. A property access for "__proto__
" that eventually consults Object.prototype will find this property, but an access that does not consult Object.prototype will not find it. If some other "__proto__
" property is found before Object.prototype is consulted, that property will hide the one found on Object.prototype.
请注意,此属性不是标准属性,某些浏览器可能没有。标准方法是:
Note this property isn't standard and some browsers may not have it. The standard way is:
-
Object.getPrototypeOf
获取内部[[Prototype]]
,在ES5中定义。 -
Object.setPrototypeOf
设置内部[[原型]]
,在ES6中定义。
Object.getPrototypeOf
to get the internal[[Prototype]]
, defined in ES5.Object.setPrototypeOf
to set the internal[[Prototype]]
, defined in ES6.
这篇关于属性“__ proto_”被储存了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!