javascript 数组去重

function quchong(array) {
  if (array instanceof Array === false) return false;
  for (let index = 0; index < array.length; index++) {

    const element = array[index];
    for (let zindex = index + 1; zindex < array.length; zindex++) {
      const zelement = array[zindex];
      if (zelement == element || zelement == undefined) {
        array.splice(zindex, 1);
        zindex--
      }
    }
  }
  return array;
}

 

posted @ 2018-12-03 19:20  飞翔的cloud  阅读(186)  评论(0编辑  收藏  举报