在JavaScript中应用函数 [英] apply function in JavaScript
本文介绍了在JavaScript中应用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习JavaScript,并且正在尝试弄清楚为什么(在 Spidermonkey 中)
[]。concat.apply([1],[[2]])
返回期望的 [1,2]
,但是
Array.concat.apply([1],[[2]])
返回 [2]
而不是 [1,2]
。
有人可以提供一个很好的解释吗?
[]。concat
是 Array.prototype.concat
。
I'm learning JavaScript and I'm currently trying to figure out why (in Spidermonkey) returns the expected returns Could someone provide a good explanation? 这篇关于在JavaScript中应用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Array.concat
是一个仅限Firefox的静态方法,用于连接一个或多个数组并忽略其[].concat.apply([1], [[2]])
[1, 2]
, butArray.concat.apply([1], [[2]])
[2]
instead of [1, 2]
. 解决方案 [].concat
is Array.prototype.concat
.Array.concat
is a Firefox-only static method that concatenates one or more arrays and ignores its this
argument.
查看全文