The Function-Variable

In JavaScript, a function is not just a statement, but a special kind of value. It can be assigned to a variable, just like a number or a string.

let sayHi = function() {
  alert("Hello!");
};

let func = sayHi; // Copy the function to another variable
func(); // Now both variables call the same function

Main Difference from Declaration

A Function Expression is created only when the execution flow reaches it. It cannot be called " in advance " .

Important

Note: it is customary to put a semicolon ; after a Function Expression, as it is essentially a variable assignment.