1.同步就是后一个任务等待前一个任务 完毕后再执行,执行顺序和排列顺序一致
2.异步。非阻塞的,主逻辑不需要等待异步逻辑完成,而是可以立即继续下去。
解决方案
1. promise
参数 resolve,reject
状态 pending fulfilled rejected
promise.then (函数)
catch(函数)
promise.all([p1,p2])成功是返回一个数组 ['成功了','success'],失败了打出失败
2.async await
3.宏任务、微任务
宏任务:setTimeout setInterval js主代码
微任务:process.nextTick Promise的then方法