What Is This Javascript Syntax? !function(){}
Possible Duplicate: What does the exclamation mark do before the function? I came across this today and have never seen before: !function($) { //contents removed }( window.jQue
Solution 1:
An exclamation mark before a function
statement creates a function expression. If you want to create a function which invokes itself, it must be an expression not a declaration.
One could achieve the same result by using a +
character for instance, or putting the whole expression into parenthesis.
+function( $ ) {}( window.jQUery );
or
(function( $ ) {}( window.jQuery ));
Post a Comment for "What Is This Javascript Syntax? !function(){}"