JS Anonymous function call method
Mode 1, call the function, get the return value. The force operator makes the function call execute
View Sourceprint?1 (function (x,y) {
2 alert (x+y);
3 return x+y;
4} (3,4));
Mode 2, call the function, get the return value. Force the function to perform a direct amount of execution and return a reference, and then invoke the execution
View Sourceprint?1 (function (x,y) {
2 alert (x+y);
3 return x+y;
4}) (3,4);
This is also the way many libraries love to call, such as Jquery,mootools.
Mode 3, using void
View sourceprint?1 void function (x) {
2 x = x-1;
3 alert (x);
4} (9);
Mode 4, using the-/+ operator
View Sourceprint?01-function (x,y) {
alert (x+y);
return x+y;
04} (3,4);
05
+function (x,y) {
alert (x+y);
return x+y;
09} (3,4);
10
One--function (x,y) {
alert (x+y);
return x+y;
14} (3,4);
15
++function (x,y) {
alert (x+y);
return x+y;
19} (3,4);
Finally look at the wrong way to call
View sourceprint?1 function (x,y) {
2 alert (x+y);
3 return x+y;
4} (3,4);