美文网首页
JS-给数组中每个对象加一个相同属性

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

作者: 陌上桑_浅 | 来源:发表于2019-07-23 11:36 被阅读0次

    新数组:array;

    原数组:list;

    给原数组list的对象加一个名为indexNum的属性,属性值为str

        let array=[];
        this.list.map((item,index)=>{
            array.push(
                Object.assign({},item,{indexNum:str})
            )
        }
    `
    

    相关文章

      网友评论

          本文标题:JS-给数组中每个对象加一个相同属性

          本文链接:https://www.haomeiwen.com/subject/khrolctx.html