Understanding promise.race() usage
As far as I know, there are two options about promise : promise.all() promise.race() Ok, I know what promise.all() does. It runs promises in parallel, and .then gives you the values if both resolved successfully. Here is an example: Promise.all([ $.ajax({ url: 'test1.php' }), $.ajax({ url: 'test2.php' }) ]) .then(([res1, res2]) => { // Both requests resolved }) .catch(error => { // Something went wrong }); But I don't understand what does promise.race() is supposed to do exactly? In other word, what's the difference with not using it? Assume this: $.ajax({ url: 'test1.php', async: true,