Understanding promise.race() usage
As you see, the race() will return the promise instance which is firstly resolved or rejected: var p1 = new Promise(function(resolve, reject) { setTimeout(resolve, 500, ‘one’); }); var p2 = new Promise(function(resolve, reject) { setTimeout(resolve, 100, ‘two’); }); Promise.race([p1, p2]).then(function(value) { console.log(value); // “two” // Both resolve, but p2 is faster }); For a scenes … Read more