在使用数组的时候,需要将两个数组的数值进行合并
var arr1 = [{
name: '梨花',
sex: 18,
age: '女',
index: 1
},
{
name: '小明',
sex: 19,
age: '男',
index: 2
},
{
name: '小蓝',
sex: 22,
age: '男',
index: 3
},]
var arr2 = [
[{
nickname:'arr1',
result:'pass',
}],
[{
nickname:'arr2',
result:'rejuect',
},
{
nickname:'arr4',
result:'',
}],
[{
name:'arr3',
result:'',
}],
];
尝试过网上的扩展运算符,Array.from()等方法都达不到效果,上述方法都是直接将两个数组的对象合并在一起。
我想要的结果为:arr1和arr2的对象合并在一起,arr1对象里面创建一个flow:[]数组存放arr2的数据
var arr3 = [
{
name: '梨花',
sex: 18,
age: '女',
index: 1,
flow:[{
nickname:'arr1',
result:'pass',
}]
},
{
name: '小明',
sex: 19,
age: '男',
index: 2,
flow:[{
nickname:'arr2',
result:'rejuect',
},
{
nickname:'arr4',
result:'',
}]
},
{
name: '小蓝',
sex: 22,
age: '男',
index: 3,
flow:[{
name:'arr3',
result:'',
}],
}
];