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); 

see http://jsfiddle.net/eb4d4/


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -