let person =[{
id: 1,
name: 'vhen'
},{
id: 2,
name: 'json'
}]
let newArr = obj.map((item,index) =>{
return Object.assign(item,{index:index})
})
js给数组中对象添加新属性
最新推荐文章于 2023-03-12 14:44:50 发布
let person =[{
id: 1,
name: 'vhen'
},{
id: 2,
name: 'json'
}]
let newArr = obj.map((item,index) =>{
return Object.assign(item,{index:index})
})