2

如果我将一个属性/函数定义为一个对象原型(假设强制最终会导致每个变量都访问该属性/函数),那么......

Object.prototype.doFunc = function(){ return 'this is ' + this;}
// OUTPUT - function(){ return 'this is ' + this;}
Object.prototype.doFunc.dontEnum = true
// OUTPUT - True

然后我for..in在一个对象上运行枚举器,doFunc即使该对象的.propertyIsEnumerable('doFunc')计算结果为False

有什么想法吗?(这同样适用于 VBA 项目中 ScriptControl 对象的原生 ECMA Script 3/JScript。)

4

0 回答 0