Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ES5/IE8设置不可枚举的属性_Javascript_Properties_Internet Explorer 8_Ecmascript 5_Enumerable - Fatal编程技术网

Javascript ES5/IE8设置不可枚举的属性

Javascript ES5/IE8设置不可枚举的属性,javascript,properties,internet-explorer-8,ecmascript-5,enumerable,Javascript,Properties,Internet Explorer 8,Ecmascript 5,Enumerable,我使用一个向数组类添加一些属性的库。 例如: Array.prototype.realFunction = function(){return true;} 这些添加的属性是可枚举的,因此它会给循环(for…in)(来自MS:D的代码)带来一些问题 所以,我编写了一些代码,将这些属性设置为不可枚举,但在IE8上不起作用 for(var p in Array.prototype) { var desc = Object.getOwnPropertyDescriptor(Arr

我使用一个向数组类添加一些属性的库。 例如:

Array.prototype.realFunction = function(){return true;}
这些添加的属性是可枚举的,因此它会给循环(for…in)(来自MS:D的代码)带来一些问题

所以,我编写了一些代码,将这些属性设置为不可枚举,但在IE8上不起作用

for(var p in Array.prototype) 
{ 
        var desc = Object.getOwnPropertyDescriptor(Array.prototype, p); 
        if(desc != null && desc.enumerable) { 
                desc.enumerable = false; 
                Object.defineProperty(Array.prototype, p, desc); 
        } 
}
我该怎么做

谢谢你的帮助,我要死了


致以最诚挚的问候

可能的重复不是重复。怎么会这样?您试图在IE8中创建一个不可枚举的属性,对吗?