Home > front end >  Var b=function test (a, b) {}; After the console. The log (test (1, 3)) why run fail
Var b=function test (a, b) {}; After the console. The log (test (1, 3)) why run fail

Time:10-07


The code is as follows:

Var b=function test (a, b) {
The console. The log (a + b)
The return of a + b
} (1, 3);//4
the console. The log (test (1, 3));

Questions as follows:

1, the the console. The log (test (1, 3)) why run failure
2, var b=function test (a, b) {} here to test the function definition or function?

CodePudding user response:

The test is not a function definition, the equivalent of temporary function object (or a function pointer)
The equivalent of
Var b=((a, b)=& gt; {//and lambda expressions of equivalent, so the test is meaningless, not allowed to use the test
The console. The log (a + b)
The return of a + b
}) (1, 3);
  • Related