52 core JavaScript questions spanning scope, TDZ, hoisting, closures, event delegation, garbage collection, memory leaks, custom async utilities, and modern ECMAScript specifications.
Preview Mode Active · 5 Free Sample Questions
Review verified answers and code patterns below. The remaining 102 questions in this codex are unlocked with the Interview Pass or Full Access.
JavaScript has three ways to declare variables, differing in scope, hoisting behavior, and mutability. var is function-scoped (or global if declared outside a function) and ignores block boundaries like if/for blocks; it is hoisted and auto-initialized to undefined, so reading it before its declaration line gives undefined rather than an error, and it can be redeclared and reassigned freely in the same scope. let is block-scoped (confined to the nearest {}), can be reassigned but not redeclared in the same block, and is hoisted but left uninitialized - accessing it before its declaration throws a ReferenceError (the temporal dead zone). const is block-scoped like let, must be initialized at declaration, and its binding cannot be reassigned - but this only makes the binding immutable, not the value: obj.x = 1 still works on a const object, only obj = {} would fail. In modern code, const is preferred by default, let when reassignment is needed, and var is generally avoided because of its function-scoping and hoisting footguns.
for (var i = 0; i < 3; i++) {}
console.log(i); // 3 - leaked out of the loop
for (let j = 0; j < 3; j++) {}
console.log(j); // ReferenceError - j is block scopedYou have reached the end of the 5 free preview questions. Get unrestricted lifetime access to all 107 questions, model solutions, architectural blueprints, and complete DSA codex.
One-time settlement · Lifetime access · Zero recurring bills