3

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

I ran across a function definition style that is new to me while browsing the Emile animation library:

!function () {
       // do something
}();

I'm familiar with:

  • Function expressions: var foo = function (){}
  • Named function expressions: var foo = function bar(){}
  • Function declarations: function foo(){}
  • Immediate functions: var foo = function (){}() or var foo = (function (){})()

The snippet above uses immediate function invocation (for variable scoping, I assume), but the ! is what's throwing me off. JSLint is happy with it, so it must be kosher. What does it do?

Community
  • 1
  • 1
Gordon
  • 71
  • 3

0 Answers0