1

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

Community
  • 1
  • 1
srcspider
  • 10,977
  • 5
  • 40
  • 35
  • Same question is answered [here](http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function) & [here](http://stackoverflow.com/questions/5422585/preceding-function-in-javascript/5422658#5422658). – viclim Jun 25 '12 at 09:49

1 Answers1

1

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

Mathieu
  • 5,495
  • 2
  • 31
  • 48