Why create an anonymous function with a ! before it?
Possible Duplicate:
What does the exclamation mark do before the function?
What's the point of the !
in the snippet bellow?
!function ($) { // code }(window.jQuery);
This syntax is used extensively in Twitter's bootstrap.js
they are calling the function right after the declaration (with window.jQuery as a parameter)
another syntax is:
(function ($) {
// code
})(window.jQuery);
some people care more about one character than readability
链接地址: http://www.djcxy.com/p/96894.html上一篇: `!function()`是什么意思?
下一篇: 为什么创建一个匿名函数! 在之前呢?