Created
September 18, 2017 02:20
-
-
Save hnakamur/f456f37e849a6853ea2ace0c47a372b7 to your computer and use it in GitHub Desktop.
await in loop experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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