function myFunc(){} is a global function literal; it does not immediately "start", but can refer to forward and backward . Value:
myFunc();
How in:
myFunc(); // this will **not** run myFunc = function (){}
The difference with the second function is that even if you did not declare var myFunc = . It becomes a global variable (also known as a built-in anonymous function), different from a global built-in function, because it must be above a certain number (backward link) to use.
function setGloabalVariable(){ window.variable = '1'; // this could have been written // variable = '1'; var variable = '1'; // unless this function is called in some global scope, the closure won't // bring out this variable }
An anonymous function runs instantly, and I think this is what you are thinking about (but not in your OP).
(function () { }());
An article about autonomous anonymous functions
Anonymous functions created a local / internal scope. Great for creating namespaces and storing objects in a namespace.
source share