异步同步问题

1.回调函数

function timer(time, callback){
    setTimeout(function(){
        callback();
    }, time);
 }

 timer(3000, function(){
   console.log(123);
 })


timer()




async function testResult() {
    let first = await doubleAfter2seconds(30);
    let second = await doubleAfter2seconds(50);
    let third = await doubleAfter2seconds(30);
    console.log(first + second + third);
}

你可能感兴趣的:(异步同步问题)