call stack

function doMath(x,y){
    return square(x) - square(y);
}


function square(num){
   console.log(Error().stack);
   return multiply(num,num);
}

function multiply(x,y){
    return x * y;
}

doMath();
doMath();

Which functions will be on the call stack when the call stack is logged inside the square() function for the first time? Functions are listed from left to right in order of call stack height

loop-with-timeout.jsfor(var i=0;i console.log(i), 0) }

¿Cual es la salida?

for(var i=0;i<=3; i++) {
    setTimeout(()=> console.log(i), 0)
}

let-loop-with-timeout.jsfor(var i=0;i console.log(i), 0) }

¿Cual es la salida?

for(let i=0;i<=3; i++) {
    setTimeout(()=> console.log(i), 0)
}

loop-blocking-timeout.js

¿Cual es la salida?

let start = new Date;
setTimeout(() => {
    var end = new Date;
    console.log("Elapsed time: "+(end - start));
  }, 
  500);
while (new Date - start < 1000) {}

event queue and call stack

There are currently several functions on the call stack that are in the process of running.

The event queue is empty.

A mouseclick event occurs and puts a new task onto the event queue.

What happens next?