Skip to content
目录

数组中对象添加新属性

javascript
let person = [
  { id: 1,name: 'vhen'},
  { id: 2,name: 'json'}
]

let newArr = obj.map((item, index) => {
  return Object.assign(item, { index: index })
})

Released under the MIT License.