Using console.log to see which function gets executed first

I was told if I put a console log in the beginning of both functions I would be able to see which gets executed first.

Am I doing it wrong?

I was expecting the console.log on each to both be pointing to the function that gets called first, no matter what the order of the functions were.

Is there a way to do that using console.log ?

First: console.log("hit2");

Second: console.log("hit1");

https://jsfiddle.net/phqmLd4a/

const manageCover = (function makeManageCover() {

  console.log("hit2");
  ...

})();


const manageUI = (function makeManageUI() {

  console.log("hit1");
  ...

})();

First: console.log("hit1");

Second: console.log("hit2");

https://jsfiddle.net/tp6z4gh0/

const manageUI = (function makeManageUI() {

  console.log("hit1");
  ...

})();


const manageCover = (function makeManageCover() {

  console.log("hit2");
  ...

})();

Those are IIFEs. They will be executed as soon as they are encountered - that is part of the point of IIFEs.

2 Likes