SOURCE

console.log('start')
let a = [1, 2, 3]
let wait = (param) => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve()
            console.log(param)
        }, 1000 * param)
    })
}

// for (const item of a) {
//     (async function() {
//         await wait(item)
//     })()
// }

a.forEach(async (item) => {
    await wait(item)
})
console.log('end')
console 命令行工具 X clear

                    
>
console