Search code examples
javascriptfunctionsizzle

JavaScript !function(){}


when looking at the minified Sizzle code, I noticed that it begins like this:

!function(a){//...

  }(window)

Why is there an exclamation point at the beginning?

I thought that ! was the not operator.

Thank you.

Edit:

Full Code.


Solution

  • !function(a){/* ... */}();
    

    Using an unary operator to invoke an IIFE is common practice. That's a common shorthand for:

    (function(a){/* ... */}());
    

    or:

    (function(a){/* ... */})();
    

    You can also substitute the not unary operator with any other unary operator:

    -function(a){ /* ... */ }();
    +function(a){ /* ... */ }();
    /* ... etc. */