How JS Works

Learn how the JavaScript engine executes code.

Examples

Call Stack Visualization

The engine pushes printSquare(), then multiply(), then log() onto the stack.

function multiply(x, y) {
  return x * y;
}
function printSquare(x) {
  var s = multiply(x, x);
  console.log(s);
}
printSquare(5);

Blocking Code

Understanding how synchronous code blocks execution.

// This loop blocks the execution
// alert("Hello");
console.log("This will not run until alert is closed");

Asynchronous Callback

Shows how the Event Loop handles async operations (Output: 1, 3, 2).

console.log("1");
setTimeout(() => {
  console.log("2");
}, 1000);
console.log("3");

Test Your Knowledge

JavaScript Quiz

No quiz available for this topic yet.