The one of the Javascript anonymous function syntax

The JavaScript anonymous function has many syntax style. The one of the useful style is wrapped function by a brackets and follow another brackets. Second brackets could let you input function's parameter. For example:


(function(p1){
    alert(p1);
})(parameter1);


Many open source js packages were used this syntax to prevent global variable. It's can let user easy to integrate and do not worry about the variables conflict.

留言

熱門文章