Consider this piece of code:
Promise.race([
new Promise(_ => setTimeout(() => _("first one"), 999.1)),
new Promise(_ => setTimeout(() => _("second one"), 999)),
]).then(console.log)
Nothing Fancy Here.
Its A Simple Promise.race
which as far as i know:
Takes In An Iterable Of Promises and returns the value of the promise which resolves first.
According to the above definition, the second promise should resolve first as it has a 0.1
less delay than the first one.
So The Expected output should be:
second one
But strangely, the actual result is first one
Why is this so? is there something i'm missing or rather misinterpreting?