The functions are the same, but the meaning is a little different. The first is to define a variable and let the anonymous function assign the value.
The second is an ordinary non-anonymous function, which is the same when called. You should I know that the immediate execution function is somewhat similar to the anonymous one
In short, you can write it however you want, as long as it can be called
The functions are the same, but the meaning is a little different. The first is to define a variable and let the anonymous function assign the value.
The second is an ordinary non-anonymous function, which is the same when called. You should I know that the immediate execution function is somewhat similar to the anonymous one
In short, you can write it however you want, as long as it can be called
These are the two most basic ways of function declaration.
var add = function () { }
This method defines the namespace as add to avoid duplication of method names in other class libraries.
function add() { }
This is a general way of writing, and it is easy to cause naming conflicts when using various plug-ins.