Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 函数前的感叹号有什么作用?
!下面的片段中有什么意义?
!
!函数 ($) { // 代码 }(窗口.jQuery);
此语法在Twitter 的 bootstrap.js中广泛使用
他们在声明之后立即调用该函数(以 window.jQuery 作为参数)
另一种语法是:
(function ($) { // code })(window.jQuery);
有些人更关心一个字符而不是可读性