function (){
alert('a function');
}
when i put it on the firebug javascript control. it shows function statement requires a name
(function (){
alert('a function');
}())
when i put the above it shows ok.
function (){
alert('a function');
}()
it also shows function statement requires a name and doesn’t execute the function. why?
is a function statement, so it requires a name.
The
()change the statement to an expression, so it’s OK.And you could also use the below ways.