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
Post a Comment