//第一种 一个数组中的值为key 一个数组中的值为value let arr1 = ['内存','颜色','尺寸']; let arr2 = [1,2,3]; let temp = arr1.map((value,index,arr) => { let json = {}; json[value] = arr2[index] return json }); console.log(temp); //第二种 一个数组中的值为对象['desc']值 一个数组中的值为对象['name']的值 let result = arr1.map((value,index) => ({desc:value, name:arr2[index]})); console.log(result);
【js】将2个数组合并为一个数组
猜你喜欢
转载自www.cnblogs.com/websmile/p/11791677.html
今日推荐
周排行