美文网首页
js 数组中将某一对象元素进行替换

js 数组中将某一对象元素进行替换

作者: 魔仙堡杠把子灬 | 来源:发表于2020-05-29 16:28 被阅读0次

我从未打过折扣

前端QQ群: 981668406
在此附上我的QQ: 2489757828 有问题的话可以一同探讨
我的github: 李大玄
我的私人博客: 李大玄
我的简书: 李大玄
我的CSDN: 李大玄

var asd = {name: '李四', age: 12};
let list = [
    {name: '张三'},
    {name: '李四'}
]
list = list.map(t => {
    return t.name === asd.name ? asd: t;
  });
 console.log(list)

相关文章

网友评论

      本文标题:js 数组中将某一对象元素进行替换

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