Object.prototype不可枚举?

时间:2015-07-01 13:11:35

标签: prototype enumerable

这可能是愚蠢但是你可以解释一下这句话,因为我觉得我不应该这样理解。 “从Object.prototype继承的属性不可枚举,因此for / in循环不显示它们” 那么为什么下面的for循环显示了print函数和author属性?

function PrintStuff (myDocuments) {
this.documents = myDocuments;
}
PrintStuff.prototype.print = function () {
console.log(this.documents);
}
PrintStuff.prototype.author = “Stephen King”;
var newObj = new PrintStuff();
for (x in newObj) {
console.log(x);
}  
//documents, print, author.

0 个答案:

没有答案
相关问题