FUNCTION EXPRESSIONS
One of the more powerful, and often confusing, parts of JavaScript is function expressions. There are two ways to define a function: by function declaration and by function expression. The first, function declaration, has the following form:
function functionName(arg0, arg1, arg2) {// function body}
One of the key characteristics of function declarations is function declaration hoisting, whereby function declarations are read before the code executes. That means a function declaration may appear after code that calls it and still work:
sayHi();function sayHi() {console.log("Hi!");}
This example doesn't throw an error because the function declaration is read first before the code begins to execute.
The second way to create a function is by using a function expression. Function expressions have several forms. The most common is as follows:
let functionName = function(arg0, arg1, arg2) {// function body};
This pattern of function expression...