When we write programs by js, we will write many functions and call them. So when do we add () and when do we add () when these functions are called? Remember the following points.
(1) Do not bracket when making parameters of functions.
function fun(e) { alert(e); } function A(fun, e) { fun(e); } A(fun, 3);//Pop '3', function fun is passed into another function as an actual parameter, and no () is added(2) The function must be called with brackets.
Look at the above code, the function A in line 9 is called A();
(3) When the function is on the right side of the assignment symbol, when there is no (), the function object is passed, and when there is (), the function return value is passed.
function Fun() { return 1; } var a = Fun(); //A at this time a = 1 var b = Fun; //b is a reference to a functionThe function name without () is used as a reference to a function, or a pointer, to pass the location of the function. If necessary, find this function to execute.