1

Possible Duplicate:
What does the exclamation mark do before the function?

I am looking at the bootstrap Javascript provided by the Bootstrap, from Twitter.

And the first thing I notice in the file is !function( $ ) What is the purpose of ! in front of the function here?

Also notice the end: what is that for?

Here is the actual code block, incase you are interested:

!function( $ ) {

  $(function () {

    "use strict"

    /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
     * ======================================================= */

    $.support.transition = (function () {
      var thisBody = document.body || document.documentElement
        , thisStyle = thisBody.style
        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined

      return support && {
        end: (function () {
          var transitionEnd = "TransitionEnd"
          if ( $.browser.webkit ) {
            transitionEnd = "webkitTransitionEnd"
          } else if ( $.browser.mozilla ) {
            transitionEnd = "transitionend"
          } else if ( $.browser.opera ) {
            transitionEnd = "oTransitionEnd"
          }
          return transitionEnd
        }())
      }
    })()

  })
Community
  • 1
  • 1
Moon
  • 33,439
  • 20
  • 81
  • 132
  • 2
    see http://stackoverflow.com/questions/3755606/what-does-the-exclamation-mark-do-before-the-function – Dominic K Feb 02 '12 at 00:19
  • 1
    Look especially at the second answer on that page, and compare the `!` technique to the `()` technique used in the `end` property definition. – lonesomeday Feb 02 '12 at 00:22
  • The `end:` is simply a key in an object literal (notice the `{` at the end of the line before it). – josh3736 Feb 02 '12 at 00:41

0 Answers0