javascript - Self Invoking functions difference -


this question has answer here:

what difference between these 2 self invoking functions? function not work if ! (not) symbol added.

please clarify if 1 has clear understanding.

// first (function( $ ) {    // ... })( jquery );   // second !function($){     alert("test1"); }(jquery), function(){    alert("test2"); }(jquery); 

  1. !function () {} means negative function (similar if (!somevar) {}), make sure result before making negative, function must executed. ! can replaced +.

  2. you have wrong //second, because create 2 anonymous functions , between there ,. think getting syntax error in place, next function not work (and not executed, because no 1 calling function)


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -