Sleep in JavaScript

- 120 views

A function to pause execution.

function sleep(ms: number) {
  return new Promise((resolve) => setTimeout(resolve, ms));
}

Moved the page from under /snippets to /blog on the 10th of February 2024.