function - What does this JavaScript snippet mean? -


this question has answer here:

i have not met type of grammar before. mean? technique related?

(function(fun) {   })(myfunkyalert); 

this anonymous function run declared. parameter myfunkyalert , inside function referenced fun variable.

the reason write function avoid conflicts, due scoping.

example:

var myfunkyalert = "the funky alert";  (function(fun) {     alert(fun); })(myfunkyalert); 

this result in alert message "the funky alert".


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -