Why does Array.prototype return an empty array?

后端 未结 2 534
你的背包
你的背包 2021-01-14 00:53

It might be a stupid question, but why do I get an empty array when I console out Array.prototype ?

I was expecting the push and pop methods.

相关标签:
2条回答
  • 2021-01-14 01:22

    "Note: Array.prototype does not refer to a single array, but to the Array() object itself." - http://www.w3schools.com/jsref/jsref_prototype_array.asp

    0 讨论(0)
  • 2021-01-14 01:24

    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). Since they not enumerable, they won't show up if you "console them out".

    0 讨论(0)
提交回复
热议问题