es6使用map方法改变数组中某一对象的值

@https://blog.csdn.net/m0_47531829/article/details/124753490

const data = [
  {
    name: "张三",
    age: 12,
    _check: true,
  },
  {
    name: "李四",
    age: 15,
    _check: true,
  },
  {
    name: "王五",
    age: 18,
    _check: false,
  },
];
data.map(item => {
    if(item._check) {
        item._check = false
    }
    return item
})
console.log(data,'data');

posted @ 2024-01-03 12:39  bitterteaer  阅读(95)  评论(0编辑  收藏  举报