gpt4 book ai didi

javascript - Javascript concat 方法的结果顺序

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:58:23 24 4
gpt4 key购买 nike

连接结果的顺序是否始终保留?

var alpha = ['a', 'b', 'c'];
var numeric = [1, 2, 3];

alpha.concat(numeric);
// result in ['a', 'b', 'c', 1, 2, 3]

最佳答案

是的,是的。

From MDN (强调我的):

The concat method creates a new array consisting of the elements in the object on which it is called, followed in order by, for each argument, the elements of that argument

来自ECMAScript spec (强调我的):

When the concat method is called with zero or more arguments, it returns an array containing the array elements of the object followed by the array elements of each argument in order.

关于javascript - Javascript concat 方法的结果顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50108821/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com