Skip to main content

var, let, const and the temporal dead zone

Compare scope, reassignment and how each declaration behaves when read before its declaration is evaluated.

Official Reference

Model Answer & Explanation

var is function-scoped inside a function and initialized to undefined before its declaration executes. let and const are block-scoped and cannot be accessed before initialization (the temporal dead zone). const requires an initializer and prevents rebinding, not mutation of the value it refers to.

Follow-up Interview Question · Can typeof throw for a name declared later in the same block?

Module Context & References

JavaScript · Language theory Explain scope, closures, this, prototypes, equality and references
Personal Notes · Markdown

Technologies & Interview Topics Covered

Switch between short-term interview tracks and long-term 80/20 engineering depth to practice JavaScript internals, React rendering and hooks, timed frontend machine coding UI challenges, MeetaPro FG300, Blind 75 & NeetCode 150 DSA patterns, Python & FastAPI APIs, PostgreSQL query optimization & MVCC, Redis caching, Applied AI RAG pipelines & evaluations, and distributed system design.