我有两个类似的 json 数组
var json1 = [{id:1, name: 'xxx' ...}]
var json2 = [{id:2, name: 'xyz' ...}]
我希望它们合并到单个数组中
var finalObj = [{id:1, name: 'xxx' ...},{id:2, name: 'xyz' ...}]
最佳答案
你想要 concat
方法。
var finalObj = json1.concat(json2);
https://stackoverflow.com/questions/10384845/