gpt4 book ai didi

javascript - 将数组添加到数组项中

转载 作者:行者123 更新时间:2023-11-30 11:04:12 26 4
gpt4 key购买 nike

我正在填充一个 json 文件,我有一个这样的数组

[{ name: name, address: address, age: age }]

[{ name2: name2, address2: address2, age2: age2 }]

现在,我想合并这两个数组,我期待这样的结果

[
{ name: name, address: address, age: age },
{ name2: name2, address2: address2, age2: age2 }
]

最佳答案

另一种选择...

var array1 = [{ name: name, address: address, age: age }]
var array2 = [{ name2: name2, address2: address2, age2: age2 }]

var merged = array1.concat(array2)

关于javascript - 将数组添加到数组项中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56377768/

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