SOURCE

console 命令行工具 X clear

                    
>
console
// 当收到多个异步回调时,实际是在同步执行
var dom1 = document.querySelector('#fn1')
var dom2 = document.querySelector('#fn2')

function delay(ms=0){
    return new Promise (resolve=>{
        setTimeout(resolve,ms)
    })

}

async function fn1(){
    await delay(3000)
    console.log('fn1')

}

async function fn2(){
    await delay()
    console.log('fn2')

}
// 虽然里面await了但是接收到fn2回调时,还是会先执行
dom1.onclick = async ()=>{await fn1()}

dom2.onclick = async ()=>{await fn2()}
<button id='fn1'>click1</button>
<button id='fn2'>click2</button>