我有一个包含另外2个对象数组的数组,我想将其变成单个对象数组。我已经发布了当前的代码和想要的结果
我尝试了concat方法,但可能实现错误?
var code = [
[{Adults:"1", Price: "14.50"}],
[{Adults:"1", Price: "20.50"}]
]
var result = [
{Adults: "1", Price: "14.50" },
{Adults: "1", Price: "20.50"}
]
答案 0 :(得分:1)
您可以使用flat
var code = [
[{Adults:"1", Price: "14.50"}],
[{Adults:"1", Price: "20.50"}]
]
let op = code.flat()
console.log(op)