美文网首页
js 根据chatId 删除数组重复元素

js 根据chatId 删除数组重复元素

作者: 安徒生1997 | 来源:发表于2022-07-20 11:40 被阅读0次

    let msgLists = that.msgList.concat(msgObj);

            that.msgList = msgLists.reduce(function (tempArr, item) {

              if (tempArr.findIndex((ele) => ele.chatId === item.chatId) === -1) {

                tempArr.push(item)

              }

              return tempArr

            }, [])

    相关文章

      网友评论

          本文标题:js 根据chatId 删除数组重复元素

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