What is the key difference between a function declaration and a function expression in JavaScript?
The key difference between function declarations and function expressions is hoisting behavior. Function declarations are hoisted completely, meaning both the declaration and the function body are moved to the top of their containing scope during compilation. This allows you to call the function before its actual declaration in the code. Function expressions, on the other hand, follow variable hoisting rules—only the variable declaration is hoisted, not the function assignment. If you try to call a function defined as an expression before its definition, you'll get an error (typically 'not a function'). For example, `functionName()` followed by `function functionName() {}` works fine, but `expressionName()` followed by `const expressionName = function() {}` throws an error because at the point of calling, `expressionName` is undefined, not a function.