var allArr=[];
var arr1 = [
{spec: "颜色:蓝色;尺寸:XL;牌子:好奇1"},
{spec: "颜色:蓝色;尺寸:XL;牌子:好奇2"},
{spec: "颜色:蓝色;尺寸:XL;牌子:好奇5"}
]
var arr2 = [
{key: "28_307_311"},
{key: "28_307_312"},
{key: "28_307_315"}
];
var arr3 = [
{sku: "80"},
{sku: "90"},
{sku: "100"}
];
allArr=arr1.map((arr, index) => {return {...arr,...arr2[index],...arr3[index]};});
console.log(allArr)
//结果如下:
// [
// { spec: "颜色:蓝色;尺寸:XL;牌子:好奇1", key: "28_307_311", sku: "80" },
// { spec: "颜色:蓝色;尺寸:XL;牌子:好奇2", key: "28_307_312", sku: "90" },
// { spec: "颜色:蓝色;尺寸:XL;牌子:好奇5", key: "28_307_315", sku: "100"}
// ]
js多个数组对象合并
最新推荐文章于 2024-08-26 14:00:09 发布