JavaScript Sleep Link to heading
const sleep = ms => new Promise(r => setTimeout(r, ms));
await sleep(1000)
// as a one liner
await new Promise(r => setTimeout(r, 2000));
Celso Benedetti
const sleep = ms => new Promise(r => setTimeout(r, ms));
await sleep(1000)
// as a one liner
await new Promise(r => setTimeout(r, 2000));