Function expressions
Another way to define a function is by using a function expresison.
To define a function expresion we use a
function
keyword without using a function nameSuch functions are known as anonymous functions
A function expression is often stored inside a variable in order to refer to it
To declare a function expression:
Define a variable with
const
which is now a common practice since the release of ES6 version of JavaScriptThis variable will contain the value of the anonymous function which we define with arguments
Then we put tasks inside the function body with arguments
Example:
Another example:
Last updated