Created
April 7, 2019 18:45
-
-
Save khaosdoctor/0d640441fc8319db81fb20fbb5d884a0 to your computer and use it in GitHub Desktop.
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 p1 = Promise.race([ | |
new Promise(resolve => setTimeout(resolve, 4000)), | |
new Promise((resolve, reject) => setTimeout(reject, 8000)) | |
]) | |
const p2 = Promise.race([ | |
p1, | |
new Promise(resolve => setTimeout(resolve, 6000)), | |
new Promise(resolve => setTimeout(resolve, 10000)), | |
new Promise((resolve, reject) => setTimeout(reject, 2000)) | |
]) | |
p2.then(result => console.log(result)) | |
p2.catch(err => console.error(err)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment