Something that I cannot find the exact answer.
In Promise.race after the first fulfillment takes place, do the rest promises keep running or they are rejected?
Something that I cannot find the exact answer.
In Promise.race after the first fulfillment takes place, do the rest promises keep running or they are rejected?
The answer is yes, they keep running. You can see the answer yourself
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
console.log('completing promise1 after 1 sec')
resolve('one');
}, 1000);
});
const promise2 = new Promise((resolve, reject) => {
setTimeout(() => {
console.log('completing promise2 after .5 sec')
resolve('two');
}, 500);
});
Promise.race([promise1, promise2]).then((value) => {
console.log(value);
// Both resolve, but promise2 is faster
});