Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 946 Bytes

File metadata and controls

59 lines (42 loc) · 946 Bytes

Execution & Behavior

Synchronous vs Asynchronous

  • Synchronous code runs line-by-line.
  • Asynchronous code allows work to continue while waiting (timers, IO, network).
console.log("A");
setTimeout(() => console.log("C"), 0);
console.log("B");
// Output: A, B, C

Execution Context

When JS runs code, it creates execution contexts (global, function, eval).

Conceptually includes:

  • Variable environment (bindings)
  • Scope chain
  • this binding

Practical takeaway: understand hoisting, scope, and this.

Strict Mode

Strict mode removes some silent errors and changes defaults.

"use strict";

function f() {
  // In strict mode, `this` is undefined for plain calls.
  return this;
}

console.log(f()); // undefined

Call Stack

The call stack tracks active function calls.

function a() {
  b();
}
function b() {
  c();
}
function c() {
  return;
}
a();

Too-deep recursion => stack overflow.