Function block (function)
Hello everyone, Lin Fei to answer the above questions for you, function block,function many people do not know, now let's take a look at it!
How do I use the function function? This paper mainly introduces several methods of defining functions in JSfunction. Friends in need can refer to the four methods of defining functions in JSfunction.
The 1.function function is basically used as a function declaration for a notebook.
The following code is 3360.
Functionfunc () {} or Val func=function () {}
The 2.function function is used as a class constructor
The following code is 3360.
The 3.function function is used as a closure:
The following code is 3360.
The 4.function function can be used as a selector:
The following code is 3360.
The mixed application of 5.function function in four cases:
The following code is 3360.
6. Use the function function to process the js script returned by ajax:
The way to construct the function: varfunc=newfunction (args1,args2,args3,body) args: parameter (any number); Body: functional body. For example:
Var func=newFunction ('arg1', 'arg2', 'alert (arg1': 'arg2)'); func ('ooo', 'PPP')
It is important to note the format of the return code. According to the processing principle, the return form can be:
1.function () {/ / code}) ()
2. {avut 'ABC', func: function {}} / / Hash table
3. Function () {}
The above three should handle most of the code.
At the end of this article, I hope it will be helpful to you.