简体   繁体   English

为什么Array.prototype返回一个空数组?

[英]Why does Array.prototype return an empty array?

It might be a stupid question, but why do I get an empty array when I console out Array.prototype ? 这可能是一个愚蠢的问题,但是当我退出Array.prototype时为什么会得到一个空数组?

I was expecting the push and pop methods. 我期待push和pop方法。

Most of the built-in methods of prototypes are not enumerble, so they won't show up if you use for..in (which you shouldn't on arrays, but this is just an example). 大多数的内置原型的方法不是enumerble,所以他们不会显示出来,如果你使用for..in (你不应该阵列,但是这只是一个例子)。 Since they not enumerable, they won't show up if you "console them out". 由于它们无法枚举,因此如果您“将它们淘汰”,它们将不会显示。

"Note: Array.prototype does not refer to a single array, but to the Array() object itself." “注意:Array.prototype不是引用单个数组,而是引用Array()对象本身。” - http://www.w3schools.com/jsref/jsref_prototype_array.asp -http://www.w3schools.com/jsref/jsref_prototype_array.asp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM