json数组数据处理

1.根据数组某一项去重
function uniqueArray(array, key) {
  let result = []
  array.map((item, index) => {
    let repeat = false
    result.map((itm, ind)=> {
      if(itm[key] === item[key]) {
        return repeat = true
      }
    })
    if (!repeat) {
      result.push(item)
    }
  })
  return result
}
posted @ 2021-02-04 16:39  jason_jia  阅读(153)  评论(0)    收藏  举报