对象数组去掉相同属性值的项

const allArr = []
      const oldArr = payload.data
      for (let i = 0; i < oldArr.length; i += 1) {
        let flag = true
        for (let j = 0; j < allArr.length; j += 1) {
          if (oldArr[i].code === allArr[j].code) {
            flag = false
          }
        }
        if (flag) {
          allArr.push(oldArr[i])
        }
      }
posted @ 2020-07-23 11:48  Evo1uti0n  阅读(278)  评论(0编辑  收藏  举报