// 红黄绿: 使用异步编程方案, promise, async await // 循环打印: 一轮打印完了以后递归重复这一过程 const taskRunner = (light, timeout) => { return new Promise((resolve) => { setTimeout(() => resolve(console.log(light)), timeout); }) } const task = async () => { await taskRunner('红',1000) await taskRunner('绿',3000) await taskRunner('黄',2000) task() } task()