__proto__适用于IE9或IE10 [英] __proto__ for IE9 or IE10

查看:685
本文介绍了__proto__适用于IE9或IE10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能更改IE9或IE10中对象的 __ proto __ 属性?
或者MS是否仍然没有计划将它包含在他们的JS引擎中?

Is there any possibility to change the __proto__ property of an object in IE9 or IE10? Or is MS still not planning to include it in their JS engine?

我需要在非常特殊的情况下需要更改 __ proto __ 创建对象后。

I need it in a very special situation where I need to change __proto__ after the object is created.

推荐答案

__ proto __ 将在ES6中标准化。它目前在 ES6草案的附录B中实际上意味着如果实现它需要具有以下语义。

__proto__ is going to be standardized in ES6. It is currently in Appendix B of the ES6 draft which in practice means that if it is implemented it needs to have the following semantics.

__ proto __ Object.prototype 表示默认情况下所有对象都可以读取和写入。但是,它可以从 Object.prototype 中删除​​(使用 delete )。删除后 __ proto __ 将作为普通数据属性,对设置没有任何副作用。

__proto__ is both available as an accessor on Object.prototype which means that all objects can read and write it by default. However, it can be removed from Object.prototype (using delete). Once deleted __proto__ will work as a normal data property with no side effects on setting.

__ proto __ 也是对象文字中的特殊句法形式。即使 Object.prototype .__ proto __ 被删除,它也可以设置[[Prototype]]。

__proto__ is also a special syntactic form in object literals. It will work to set the [[Prototype]] even if Object.prototype.__proto__ was deleted.


var p = {a: 1};
var o = {
  __proto__: p,
  b: 2
}

ES6还介绍了 Object.setPrototypeOf (不在附录中)。这比设置 __ proto __ 更受青睐。

ES6 also introduces Object.setPrototypeOf (not in the appendix). This is preferred over setting __proto__.

__ proto __ 是适用于所有现代浏览器,包括Internet Explorer 11

__proto__ is available in all modern browsers, including Internet Explorer 11.

这篇关于__proto__适用于IE9或IE10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆