《一些神奇的JS功效》

时间:2021-09-06 08:44:35

1: async 异步回调 (ES6)

async function test(){
console.log("hello wolrd");
} test().then(function(){
console.log("回调测试")
});
 

2: 沉睡排序

var numbers=[1,2,3,4,5,5,99,4,20,11,200];
numbers.forEach((num)=>{
setTimeout(()=>{
console.log(num)
},num)
})

3: 快速去重  (ES6)

var arr = Array.from(new Set([1,2,3,4,4,3,5,6,7,8,8]));

还在不断收集更新中........