Function Expressions

Understand function expressions, anonymous functions, and the difference between declarations and expressions.

Step 1 of 5

Storing a function in a variable

In JavaScript, functions are values — just like numbers and strings. You can store a function in a variable, pass it to another function, or return it from a function. A function expression creates a function and assigns it to a variable using `const`, `let`, or `var`. The function itself often has no name (it's anonymous) — the variable name is how you refer to it. Arrow functions are actually a type of function expression, since they're always assigned to a variable.

Think of it this way: A function expression is like saving a recipe to a specific shelf. Instead of just having a recipe card floating around with a name tag, you put it in a labeled container: `const makeBreakfast = function() { ... }`. The container (variable) holds the recipe (function). You find the recipe by looking at the shelf label.
Learn more on MDN
JAVASCRIPTREAD ONLY
CONSOLE
Click "Run" to execute your code...