1. 顺序输出func1 func2 func3
function func1(cb){
setTimeout(function(){
console.log('func1')
cb()
},3000)
}
function func2(cb){
setTimeout(function(){
console.log('func2')
cb()
},1000)
}
function func3(cb){
setTimeout(function(){
console.log('func3')
cb()
},2000)
}
function euque(list){
}
euque([func1,func2,func3]) //需求输出 func1 func2 func3
1
function euque(list) {
let p = new Promise(list[0]).then((res) => {
return new Promise(list[1]);
}).then(() => {
return new Promise(list[2])
})
}
2.
async function euque(list) {
for(let fn of list) {
let res = await new Promise(fn);
console.log(res);
}
}