A JavaScript function can also be defined using a function expression.
A function expression can be assigned to a variable.
const x = function (a, b) {return a * b}; |
Once a function expression is stored in a variable, the variable can be used to invoke the function.
const x = function (a, b) {return a * b}; let z = x(4, 3); |
The function above is an anonymous function, meaning it has no name.
Functions stored in variables do not require names and are always invoked using the variable name.
The function above ends with a semicolon because it is part of an executable statement. |