//正序
let arr = [22, 66, 9, 13,6];
arr.sort((x, y) => {
方式一:
return x < y ? -1 : ((x = y) ? 0 : 1)
方式二:
return x-y
})
//倒序
let arr = [10, 20, 1, 2];
arr.sort((x, y) => {
return x > y ? -1 : ((x = y) ? 0 : 1);
})
//比较两个数组差异
let a= [];
let b= [];
Array.from(new Set([...b].filter(x => !a.has(x))))