!function in javascript
JavaScript syntax 101. Here is a function declaration:
function foo() {}
Note that there's no semicolon: this is a function declaration; you need a separate invocation of
foo()
to actually run the function.
On the other hand,
!function foo() {}
is an expression, but that still doesn't invoke the function, but we can now use !function foo() {}()
to do that, as ()
has higher precedence than !
. Presumably the original example function doesn't need a self-reference so that the name then can be dropped.
So what the author is doing is saving a byte per function expression; a more readable way of writing it would be this:
(function(){})();
The leading assignment help UK firm offers state of the art services to its clients with a promise of delivering all the required work well within the deadline.
ReplyDeleteSPSS Assignment Help
Well thanks for posting such an outstanding idea. I like this blog & I like the topic and thinking of making it right.
ReplyDeleteMathCad Project Help