js知识碎片

记录 js 的知识碎片

js

// 升序排序  
arr.sort((a, b) => a - b);  
// 返回正数,说明 a 比 b 大,a 在列表后面  
// reverse 反序  
  
// 降序排序  
arr.sort((a, b) => b - a);