Skip to content

Instantly share code, notes, and snippets.

@jaydson
Created March 8, 2021 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaydson/17aeeb01d0e98e914fa80b87a88d03a5 to your computer and use it in GitHub Desktop.
Save jaydson/17aeeb01d0e98e914fa80b87a88d03a5 to your computer and use it in GitHub Desktop.
Promise.race([
new Promise((resolve, reject) => {
setTimeout(function() {
resolve('A');
}, 500);
}),
new Promise((resolve, reject) => {
setTimeout(function(){
resolve('B');
}, 300);
}),
new Promise((resolve, reject) => {
setTimeout(function(){
resolve('C');
}, 500);
}),
new Promise((resolve, reject) => {
setTimeout(function() {
resolve('D');
}, 500);
}),
new Promise((resolve, reject) => {
setTimeout(function(){
resolve('E');
}, 500);
})
])
.then(result => {
console.info(result);
})
.catch(reason => {
console.warn('Failed: ', reason);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment