Skip to content

Instantly share code, notes, and snippets.

@AshanthaLahiru
Last active April 29, 2018 11:57
Show Gist options
  • Save AshanthaLahiru/dab4e985f459acb0b4d0f9a2a57c5d50 to your computer and use it in GitHub Desktop.
Save AshanthaLahiru/dab4e985f459acb0b4d0f9a2a57c5d50 to your computer and use it in GitHub Desktop.
Async performance
let tryAsync = async () => {
let p1 = promise(1000) // |-----|
let p2 = promise(2000) // |-----|-----|
let p3 = promise(3000) // |-----|-----|-----|
console.log(await p1)
console.log(await p2)
console.log(await p3)
}
tryAsync()
//Result
/*
Promise 1000 start
Promise 2000 start
Promise 3000 start
Promise 1000 end
Promise 2000 end
Promise 3000 end
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment