let arry =[{id:1,name:'张三'},{id:2,name:'李四'}]
let arryNew = []
arry.map((item, index) => {
arryNew.push(Object.assign({}, item, { sex: '男'}))
})
es6 遍历数组, 给对象添加新属性
最新推荐文章于 2024-05-28 15:51:12 发布
let arry =[{id:1,name:'张三'},{id:2,name:'李四'}]
let arryNew = []
arry.map((item, index) => {
arryNew.push(Object.assign({}, item, { sex: '男'}))
})