Run

Promises with async/await in JavaScript

Wait for a timer with await, the way you would wait for a network request. Press Run to try it, then change the code and run it again.

main.js

const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

console.log("Starting...");
await wait(1000);
console.log("One second later");
Output

Press Run to see the output.

More JavaScript examples

Open the full JavaScript online compiler →