为什么Array.prototype返回一个空数组? [英] Why does Array.prototype return an empty array?

查看:100
本文介绍了为什么Array.prototype返回一个空数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个愚蠢的问题,但是为什么当我退出Array.prototype时为什么会得到一个空数组?

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

我期待着push和pop方法.

I was expecting the push and pop methods.

推荐答案

大多数原型的内置方法都是无法枚举的,因此如果您使用for..in(您不应该在数组,但这只是一个示例).由于它们无法枚举,因此如果您将它们淘汰",它们将不会显示.

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".

这篇关于为什么Array.prototype返回一个空数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆