anonnA
Reactiflux4y ago
7 replies
anonn

anonn – 15-18 Oct 10

Hi, I have trouble understanding how promises work in terms of the event loop.
function a() {
    console.log('a')
}

function b() {
  console.log("b");
}

function c() {
  console.log("c")
}

fetch("https://fakelinkabcabc.com").catch(a);

Promise.resolve().then(b);

Promise.reject().catch(c);

Why is the output b,c,a

Could someone explain in terms of the event loop? e.g the image attached

What actually happens when the javascript engine reaches
Promise.resolve()
? What actually happens when the
.then(b)
is reached?

I have been unable to find resources that go through step by step how interacting with Promises/Web APIs work in terms of the event loop and would be very happy if someone could point me some resources
unknown.png
Was this page helpful?