Skip to content

Instantly share code, notes, and snippets.

@hnakamur
Created September 18, 2017 02:20
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 hnakamur/f456f37e849a6853ea2ace0c47a372b7 to your computer and use it in GitHub Desktop.
Save hnakamur/f456f37e849a6853ea2ace0c47a372b7 to your computer and use it in GitHub Desktop.
await in loop experiment
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Async await loop experiment</title>
<script>
function foo(i) {
return new Promise((resolve, reject) => {
console.log('foo', i);
resolve();
});
}
(async function() {
for (var i = 0; i < 4; i++) {
await foo(i);
}
})();
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment