English 中文(简体)
IE9或IE10
原标题:__proto__ for IE9 or IE10

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__<>>>>>>。

最佳回答

<代码>proto__将在ES6中实现标准化。 它目前位于http://people.mozilla.org/~jorendorff/es6-draft.html。 《经济、社会、文化权利国际公约》草案附录B实际上意味着,如果加以实施,就必须有以下属性。

__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.

<0>proto__也是物体字面上的一种特殊合成形式。 它将努力确定[[类型],即使删除了<条码>。

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

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

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

问题回答

__proto__ is included in IE11 found in the leaked build of Windows Blue: http://fremycompany.com/BG/2013/Internet-Explorer-11-rsquo-s-leaked-build-395/

a. 非电塔作为最后一种情况:

修改你的代码,以便通过经修改的原型获得的所有原始财产现在可以通过明确授权获得正常财产:

{
   a: 17,
   __pro纽约总部__: { ... }
}

纽约总部

{
   a: 17,
   pro纽约总部: {...}
}

我不敢肯定你自问你问话以来所回过什么,但就大多数使用预言而言,你应当能够使用<条码>的

var foo = new Bar();
//this also affects foo
Bar.prototype.baz = something;

IE 9 and 10 do not support setting the prototype of an object that has already been created, but there is a hack that works in IE 9 and 10:

// An alternative to Object.setPrototypeOf() for IE 9 and 10
function addPrototypeTo(obj, prototype) {
    if (!/c/.test(typeof prototype)) {// /c/ matches function and object
        // Throws if prototype is neither an object nor null
        throw new TypeError;
    }
    if (/c|d/.test(typeof obj) && prototype) {// /c|d/ matches function, object, and undefined
        for (var prop, keys = Object.getOwnPropertyNames(prototype), length = keys.length, i = 0; i<length; i++) {
            if (!{}.hasOwnProperty.call(obj, prop = keys[i])) {// Throws if obj is nullish
                Object.defineProperty(obj, prop, Object.getOwnPropertyDescriptor(prototype, prop));
            }
        }
    }
    return obj;
}

The above function is a hack that simply copies all the properties from a prototype object and defines them on another object without overwriting any conflicting property names. Since it uses Object.getOwnPropertyDescriptor() and Object.defineProperty(), getters and setters and other property descriptors such as enumerability are maintained.

现在,如果您希望填满<代码>。

if (document.documentMode>8) {// IE 9 and above
   Object.setPrototypeOf = Object.setPrototypeOf || addPrototypeTo;
}

然而,这种黑板显然并未实际改变物体的原型。 你在要求功能后对原型进行改动,不会对物体产生影响。 因此,这不符合你们的需要。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签