The difference between: var functionName = function() {} and function functionName() {} in Javascript?
There are following two to declare function in JavaScript
function declaration:
function foo(){} // foo();
Function declaration is a normal function you can call it normally like other function calling by its name.
function expression:
var someVariable = function() { //do your code };
Function expression is also known as “anonymous function” because it does not any name. When you need to call function expression you need to declare it to variable. then you can access function using that variable.