Skip to content

Instantly share code, notes, and snippets.

@shogonir
Created November 4, 2016 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shogonir/abf1e2ec2393cd723427bc4462fabb6d to your computer and use it in GitHub Desktop.
Save shogonir/abf1e2ec2393cd723427bc4462fabb6d to your computer and use it in GitHub Desktop.
sleep with JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Web Worker 99</title>
</head>
<body>
<script type="text/javascript">
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
sleep(5000).then(
() => {
console.log('good morning');
}
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment