Created
March 18, 2019 17:49
-
-
Save lisovskyvlad/99b93b8571cf29a870e531ff335260f8 to your computer and use it in GitHub Desktop.
Learning of promises
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
const f = (wait_count, string) => ( | |
new Promise((res, rej) => (setTimeout(() => res(string), wait_count))) | |
); | |
async function sequence() { | |
const a = await Promise.all([ | |
f(2000, '2000 wait'), | |
f(500, '500 wait'), | |
f(1000, '1000 wait') | |
]); | |
console.log(a); | |
} | |
sequence() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment