JS-给数组中每个对象加一个相同属性

新数组:array;

原数组:list;

给原数组list的对象加一个名为aaaaa的属性,属性值为'11111'

 let array=[];
    this.list.map((item,index)=>{
        array.push(
            Object.assign({},item,{'aaaaa','11111'})
        )
    })

然后打印   console.log(array);   即可看到需要的值

发布了248 篇原创文章 · 获赞 602 · 访问量 108万+

猜你喜欢

转载自blog.csdn.net/qq_32963841/article/details/103956768