The code below gives the following error: VM502:1 Uncaught SyntaxError: Function statements require a function name and I assume it doesn't work because, as per the error message, function declarations require a function name.
function (){
var a = 'dog';
console.log(a);
}
The second code below doesn't produce an error, but gives "dog", because it is not a function declaration but an immediately invoked function expression...
(function(){
var a ='dog';
console.log(a);
})()
Why don't functions inside iife require a name?