Skip to main content

Hoisting · function declarations vs expressions

Why can you call a function declaration early but not a function expression assigned to a const?

Official Reference

Model Answer & Explanation

A function declaration’s binding is initialized with the function before ordinary statements in its scope execute. A function expression produces a function when the expression is evaluated. With const or let, early access hits the TDZ. With var, the early value is undefined, so invoking it throws TypeError.

Follow-up Interview Question · Explain the difference between the binding existing and being initialized.

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.