The concept of a lot of people do not understand the function of JS

JS concept in function of a lot of people do not understand, flower boxes website Daquan stations do have a code.
Function function
- the function is a target
- function can encapsulate some functions (Code), when necessary, execute the code (Code)
- the function can save some code when you need to call
- use typeof to check a function object, will return function
* /

/ *
Declaration of method functions:
1.var Fun = new new function ( "the console.log ( 'Hello this is the first function I');");
to create a function object
can be packaged in the form of a string of the code passed to the constructor
but generally do not use a constructor in the actual development to create a function object

2. Package to the function code will not be executed immediately
function code will be executed when the function call
calls the function syntax: function objects ()
when the calling function, the function code is encapsulated in the order in
Fun ();

3. Use the function to create a function declaration
syntax:
function function name (parameter [1, 2 .......... parameter parameter N]) {
statements .......... ..
}


4. Create a function to function expression
var function name = function ([parameter 1, parameter 2 .......... parameter N]) {
statements ......... ...
}

*/

/ *
Function's return value:
1 can be used to set the return value of the function returns
: Syntax
return value of the
value of the return will be executed as a result of the function,
you can define a variable to receive the result
not of any value with it if the return statement equivalent to a return undefined,
if you do not write return function, it also returns undefined
after the return value can be of any type with

Guess you like

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