| 123456789101112131415161718192021222324252627282930313233343536373839404142 | 
async function main(){    // setTimeout(() => {    //     console.log(1)    // }, 500);    // setTimeout(() => {    //     console.log(2)    // }, 200);    // setTimeout(() => {    //     console.log(3)    // }, 100);    // setTimeout(() => {    //     console.log(4)    // }, 1000);    // return    // waitSeconds(500,()=>{console.log(1)}) // 500    // waitSeconds(200,()=>{console.log(2)}) // 700    // waitSeconds(100,()=>{console.log(3)}) // 800    // waitSeconds(1000,()=>{console.log(4)}) // 1800    // return        let res1 = await waitSeconds(500,()=>{console.log(1)}) // 500    console.log(res1)    let res2 = await waitSeconds(200,()=>{console.log(2)}) // 700    console.log(res2)    let res3 = await waitSeconds(100,()=>{console.log(3)}) // 800    console.log(res3)    let res4 = await waitSeconds(1000,()=>{console.log(4)}) // 1800    console.log(res4)}function waitSeconds(duration,handle) {    return new Promise((resolve, reject) => {        setTimeout(() => {            handle()            resolve(`等待了${duration}ms`);        }, duration);    });}main()
 |