{ return {...item, ...obj2_js两个数组对象合并">
赞
踩
var obj1 = [ { "id": 1, "name" : "Lucy" }, { "id": 2, "name" : "Tom" }, ]; var obj2 = [ { "age": "12" }, { "age": "13" } ]; //进行 数组对象合并 var obj = obj1.map((item,index) => { return {...item, ...obj2[index]}; }); console.log(obj); //以下为打印出来 的内容 var obj = [ { "id": 1, "name" : "Lucy", "age": "12" }, { "id": 2, "name" : "Tom", "age": "13" }, ];
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。