setTimeout 實現
setTimeout(function() { console.log('1s') setTimeout(function() { console.log('2s') }, 1000) }, 1000)
Promise 實現
const wait = () => new Promise((resolve, reject) => { setTimeout(resolve, 1000) }) wait().then(() => { console.log('1s') return wait() }) .then(() => console.log('2s'))