Just for the sake of completeness. In these very similar examples, here's what happens without a parameter
var x = 'a'; ( function( ) { //note that there is no parameter here x = 'b'; alert('inner:'+x); //b } )(); alert('outer:'+x); //b
and var with the same name
var x = 'a'; ( function( ) { var x = 'b'; alert('inner:'+x);
source share