Tag
scope
Published articles tagged scope.
Execution contexts and the call stack
Every running piece of code has an execution context that says where its variables are, what this is, and which realm's built-ins it sees. This chapter follows contexts onto and off the call stack, explains hoisting, closures, suspension, and realms in those terms, and shows how to read the stack traces that come out of it.
Variables and declarations
Three declaration keywords—var, let, and const—interact with hoisting and the temporal dead zone in ways that differ from block-scoped languages like Java or Rust. const only freezes the binding, not deep object contents. This chapter is the reference for choosing among them in modern code.