Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Array.function和Array.prototype.function之间有什么区别?_Javascript_Prototype - Fatal编程技术网

Javascript Array.function和Array.prototype.function之间有什么区别?

Javascript Array.function和Array.prototype.function之间有什么区别?,javascript,prototype,Javascript,Prototype,我发现一些函数,比如concat()push()every()都存在于Array和Array.prototype(使用firefox 57.0.1控制台) 因为原型方法存在于数组中,所以很容易混淆 此外,staic方法(Array.from(),Array.isArray()等)在哪里存在 我想我已经在某种程度上理解了javascript原型的概念,所以我好奇的是为什么原型方法(concat()push()..)在Array和Array中都是apear。原型Firefox的Array函数似乎

我发现一些函数,比如
concat()
push()
every()
都存在于
Array
Array.prototype
(使用firefox 57.0.1控制台)

因为原型方法存在于
数组中,所以很容易混淆
此外,staic方法(
Array.from()
Array.isArray()
等)在哪里存在



我想我已经在某种程度上理解了javascript原型的概念,所以我好奇的是为什么原型方法(
concat()
push()
..)在
Array
Array中都是apear。原型

Firefox的
Array
函数似乎有额外的(不一致的)“静态”方法复制原型方法,但它们将数组作为第一个参数,而不是通过隐式
this
上下文

要查看
数组的这些方法和属性,请使用:

Object.getOwnPropertyNames(Array)
在Firefox中,您将(大部分)看到与第一个屏幕截图相同的列表。我还没有弄清楚为什么
Array.isArray
在您的列表中缺失,但它确实出现在我的Firefox 57中


在Chrome中,您只能看到ES6强制使用的“静态”方法(即
Array.from
Array.isArray
Array.of
)和标准属性。

@Kris不,它不是重复的。Firefox确实有一些不属于原型的附加方法。好吧,很抱歉,你是对的,就像第二个答案中的所有升级投票者一样,被困在了相同的方式中……我的Firefox还显示了
Array.isArray
with
Object.getOwnPropertyName(Array)
但是不显示,只显示
console.log(Array)
你呢?@soonoo同样,它不会出现在
控制台.log
输出中,但会出现在对象检查器窗格中。也许这是控制台中的一个bug?谢谢,但仍然很困惑ㅠㅠ@soonoo困惑是什么?这不是你的答案,只是关于firefox的非常规行为