Chapter VI · Functions
Function Expression
A function expression defines a function inside an expression context, typically assigned to a variable.
01 How It Works
Think of storing an unlabeled file recipe inside a specific folder slot.
Unlike declarations, function expressions are not hoisted and follow standard variable assignment rules.
example.js
const multiply = function(a, b) {
return a * b;
};
1. Declare a variable.
2. Assign an anonymous or named function.
3. Call via the variable name.
02 Practical Example
Here is how you might see this concept applied in real-world code:
practical.js
const subtract = function(a, b) {
return a - b;
};
console.log(subtract(10, 5));
Key Takeaway
Expressions are not hoisted, enforcing strict top-to-bottom initialization order.