Why does Array.prototype return an empty array?

后端 未结 2 533
你的背包
你的背包 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: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".

提交回复
热议问题