JavaScript
Node.js
More than 1 year has passed since last update.

async/awaitを使用します。

const sleep = msec => new Promise(resolve => setTimeout(resolve, msec));

(async () => {
console.log('a');
await sleep(1000);
console.log('b');
await sleep(1000);
console.log('c');
await sleep(1000);
console.log('d');
await sleep(1000);
})();

/**
a
b
c
d
**/