javascript - What is this? (function(){ })() -
possible duplicates:
what javascript snippet mean?
location of parenthesis auto-executing anonymous javascript functions?
(function(){ //something here... })() <--//this part right here.
what )()
?
if change ())
?
(function(){ //something here... }()) <--//like
this declares anonymous function , calls immediately.
the upside of doing variables function uses internally not added current scope, , not adding function name current scope either.
it important note parentheses surrounding function declaration not arbitrary. if remove these, error.
finally, can pass arguments anonymous function using parentheses, in
(function (arg) { //do arg })(1);
Comments
Post a Comment