Skip to content

Instantly share code, notes, and snippets.

@cfigueiroa
Forked from mrienstra/verbose_await_promise.js
Created February 25, 2023 17:01
Show Gist options
  • Save cfigueiroa/f271e76336ba73e13933e7bd45b17470 to your computer and use it in GitHub Desktop.
Save cfigueiroa/f271e76336ba73e13933e7bd45b17470 to your computer and use it in GitHub Desktop.
await new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, 1000);
});
// ... Can be shortened to:
await new Promise(function (resolve) {
setTimeout(resolve, 1000);
});
// ... Can be shortened to:
await new Promise((resolve) => {
setTimeout(resolve, 1000);
});
// ... Can be shortened to:
await new Promise((resolve) => setTimeout(resolve, 1000));
// ... Can be shortened to:
await new Promise(resolve => setTimeout(resolve, 1000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment