In javascript :( function () () is an anonymous function

:( function in javascript () () is an anonymous function, it is mainly a function using a variable range to avoid global variables affect the entire page environment, and improve code compatibility.

(Function ()) is a standard function definitions, but not copied to any variable. So there is no name of a function, called an anonymous function. In the absence of the name of the case, not at any time, anywhere in the calling function, so once defined function, you can call it. Rear brackets () function is the meaning of running.

 

Extended Data

Function declaration: function and use the function declaration to specify the function name.

Function setfn () // encoding
function expression: function is used to declare a function , but did not specify the name of the function. An anonymous function is assigned to a variable.

var setfn = function () // coding
anonymous function: The function key is used to declare a function, but did not specify the name of the function. Anonymous function belongs to the function expression. Anonymous function has many functions. Given a variable, it will create a function. Given an event, it will be an event handler or closures and so on.

Function () // coding

Guess you like

Origin www.cnblogs.com/blogst/p/10949729.html