JS Tutorials
JS Objects
JS Functions
JS Classes
JS Async
JavaScript functions are defined with the
function
keyword.
You can use a function declaration or a function expression.
Earlier in this tutorial, you learned that functions are declared with the following syntax:
Declared functions are not executed immediately. They are "saved for later use", and will be executed later, when they are invoked (called upon).
Semicolons are used to separate executable JavaScript statements.
Since a function declaration is not an executable statement, it is
not common to end it with a semicolon.
A JavaScript function can also be defined using an expression.
A function expression can be stored in a variable: