!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(){})();

Comments

  1. Hello, thanks for taking the time to view my profile. I am an academic writer from the US who enjoys finding new topics to research and write about.
    Medical Science Assignment Help

    ReplyDelete
  2. Good way of telling, good post to take facts regarding my presentation subject matter, which i am going to deliver in my college
    Matlab Coder Matlab Help

    ReplyDelete
  3. This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.
    Central Line Theorem Stats help

    ReplyDelete
  4. Science Channel’s are giving a complete knowledge to its viewers about every thing students write done dissertation on this subjects and show its importance.
    Operations Management Project

    ReplyDelete
  5. 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.
    SPSS Assignment Help

    ReplyDelete
  6. Mike Jasson is an academic writer of the Accounting Assignment Help. Who writes quality academic papers for students to help them in accomplishing their goals.
    SEO Writing Service

    ReplyDelete
  7. Well thanks for posting such an outstanding idea. I like this blog & I like the topic and thinking of making it right.
    MathCad Project Help

    ReplyDelete

Post a Comment