//数组去重

方法一:
function dedupe(array){
    return Array.from(new Set(array));
}
console.log(dedupe([4,6,0,1,1,2,4,0,3]));//[4, 6, 0, 1, 2, 3]

方法二:
function dedupe(array){
    return [...new Set(array)];
}
console.log(dedupe([4,6,0,1,1,2,4,0,3]));//[4, 6, 0, 1, 2, 3]

//数组排序

function Sort(array){
    return array.sort(function(a, b){
       return a - b;//正序
    });
}
console.log(Sort([3,7,12,2,22,10,43,32,1]));//[1, 2, 3, 7, 10, 12, 22, 32, 43]

相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2022-02-27
  • 2021-10-30
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案