Version of sleep() in JavaScript

Here is the version of a sleep() function using an async function:

javascript
await new Promise(r => setTimeout(r, 1000))

Props to the author.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.