我有这个数组:
var test = [{
t1: {a:1, b:2, ...},
t2: {a:3, b:4, ...},
...,
},{
t3: {a:5, b:6, ...},
t4: {a:7, b:8, ...},
...,
}]
我希望它看起来像这样:
var test = [{a:1, b:2, ...},{a:3, b:4, ...},{a:5, b:6, ...},{a:7, b:8, ...}, ...]
答案 0 :(得分:0)
您可以使用函数reduce
,然后连接每个对象的值。
var test = [{ t1: {a:1, b:2}, t2: {a:3, b:4},},{ t3: {a:5, b:6}, t4: {a:7, b:8}}],
result = test.reduce((a, c) => a.concat(Object.values(c)), []);
console.log(result)

.as-console-wrapper { max-height: 100% !important; top: 0; }