7
我想使用defineProperty使屬性不會出現在for循環中,但它不起作用。這段代碼是否正確?JavaScript defineProperty使一個屬性不可枚舉
function Item() {
this.enumerable = "enum";
this.nonEnum = "noEnum";
}
Object.defineProperty(Item, "nonEnum", { enumerable: false });
var test = new Item();
for (var tmp in test){
console.log(tmp);
}
應當標註這是正確的答案,@洛倫佐-C。 – jackyalcine 2012-09-07 20:57:24