What is the difference between a function declaration function myVar() {}
and a function expression var myVar = function() {};
?
In order to properly understand the (subtle) differences between a function declaration and a function expression we'll need to dive into the inner workings of JavaScript a little bit.
Consider this:
console.log(myVar); // ReferenceError: myVar is not defined