function muti(num){ return new Promise(resolve=>{ setTimeout(()=>{ resolve(num * num) },1000) }) } const nums = [1,2,3] //同步 nums.forEach(async (i) => { const res = await muti(i) console.log(res)//一分钟后一次打印出 1,4,9 }) //异步 !(async function(){ for(let i of nums){ const res = await muti(i) console.log(res)//一个一个执行,第一个执行以后再执行第二个,一分钟后打印1,而后再一分钟后打印4 } })()