84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
上图是history在chrome控制台的显示,原型链中的函数有6个,其中的5个能被for in遍历,但是有一个又不行,为什么啊?而且不行的那个constructor在chrome控制台显示的颜色都比其他的淡
history
for in
constructor
只有具有 Enumerable (可枚举)属性的属性才能被 for ... in 遍历。constructor是最常见的不可枚举属性之一。
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_propertieshttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor
对于你的问题就参考上面的解释, 还有函数就5个。看你截图的length,已经明确告诉你了。
只有具有 Enumerable (可枚举)属性的属性才能被 for ... in 遍历。
constructor
是最常见的不可枚举属性之一。https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor
对于你的问题就参考上面的解释, 还有函数就5个。
![](http://img.php.cn/upload/image/000/000/000/4ce8ea8b7f5d4da606bddc6b82230c1e-0.png)
看你截图的length,已经明确告诉你了。