Function Hoisting and Declaration vs Expression
How function declarations, function expressions, and named function expressions differ in hoisting behavior and use cases.
JavaScript offers several ways to define a function, and the differences between them go beyond stylistic preference — they affect hoisting, naming for stack traces, and whether the function can be called before its definition appears in the source. This is a frequent early interview question because it combines hoisting knowledge with basic syntax literacy.
A function declaration is like a fully-built house that's already standing when you arrive, ready to walk into. A function expression is like an empty lot with a sign showing whose house will eventually be built there — the sign (variable name) exists early, but you can't move in (call it) until construction (the assignment) actually finishes.