Skip to content

Instantly share code, notes, and snippets.

@hnakamur hnakamur/index.html
Created Sep 18, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.