When I execute the below Javascript promise.all() code I get the output as
hi
50
But is what I was expecting the output to be
50
hi
Can some one please explain me why "Hi" appeared first and then 50
Below is the code
let p1 = Promise.reject(50);
let p2 = true;
let p3 = new Promise((resolve, reject) => {
console.log("hi")
setTimeout(() => reject("hey"), 0);
});
Promise.all([p1, p2, p3])
.then(values => console.log(values))
.catch(err => console.log(err));