Written: August 15, 2026
A function declaration is hoisted as a full function, so you can call it before its line appears. A function expression assigns a function to a variable and follows that variable’s temporal rules.
Use declarations for named top-level helpers. Use expressions (including arrow functions) when passing callbacks or assigning conditionally.
Examples
// Declaration — hoisted
console.log(add(2, 3)); // 5
function add(a, b) {
return a + b;
}
// Expression — not usable before initialization
const mul = function (a, b) {
return a * b;
};
console.log(mul(2, 3)); // 6
// Arrow expression
const dbl = (n) => n * 2;
What to remember
Calling a const/let function expression before its line throws a ReferenceError (TDZ).
Declarations are clearer for recursive named functions; arrows shine for short callbacks.