数组去重

数组去重

indexOf

function onlyUnique(value, index, self) { 
    return self.indexOf(value) === index;
}

filter

var myArray = ['a', 1, 'a', 2, '1'];
var unique = myArray.filter((v, i, a) => a.indexOf(v) === i); 

Set

function uniqueArray(a) {
  return [...new Set(a)];
}

参考