2

Possible Duplicate:
!function(){ }() vs (function(){ })()

It is fairly standard common practice to write Js code like this:

function ($) {
    ...
}(jQuery)

I saw somebody using an exclamation mark first: ! function($)...

What does it actually mean, and what is that good for?

Example from Twitter Bootstrap (code retrieved 2012-03-07):

!function ($) {

  $(function(){
    ...
})

}(window.jQuery)
Community
  • 1
  • 1
Jesper Rønn-Jensen
  • 106,591
  • 44
  • 118
  • 155
  • ! is logical not operator it makes it a statement with the desired affect of having the anon func immediately executed. – user17753 Mar 07 '12 at 23:18

0 Answers0