Look at the following code:
var a = function(t) { return t; }
(1 + 2).toString();
alert(a);
What is the result?
In fact, the main problem is that there is no semicolon after the first line, so it is actually var a = function(t) { return t; }(1 + 2).toString();
First create the variable a, then execute the assignment statement, pass the anonymous function into parameter 1+2 and execute, return the result.toString(), and assign it to a.
For details, please refer to the namespace of js.
Copy the codeThe code is as follows:
var a = function(t) { return t; }
(1 + 2).toString();
alert(a);
What is the result?
In fact, the main problem is that there is no semicolon after the first line, so it is actually var a = function(t) { return t; }(1 + 2).toString();
First create the variable a, then execute the assignment statement, pass the anonymous function into parameter 1+2 and execute, return the result.toString(), and assign it to a.
For details, please refer to the namespace of js.