js function definition classification

New to js function, I feel very abstract, here I would like to explain my understanding of the function definition of it. 

Function definition classification can be divided into four areas, namely:

1. No parameters do not return value 2. There is no return parameter value 3. There is no return value of the parameter, 4 have a return value parameters.

(PS: Actual parameters: the function call, the incoming parameters;
              formal parameters: a function definition, the argument passed;
              function call, a copy of the actual parameters in the form of process parameters;
              all variables: variables defined in the outer body function ; (scope: external and internal functions can access the function body variable)
              variable defined within a function body (function realization section): the local variable (scope: use only the variables inside a function body); have the JS level scope function, external function can not access the local variables
              Note: 1.JS no block-level scope;
                      2.js scope of which has the function level;)

 

First, no parameter has no return value

  function name of the function () { 
          Alert (); 
         }

Second, there is no return value parameter

function function name (parameter) { // local variable 
               parameter. 8 = ;
                IF (parameter> 10 ) { 
               Alert ( "eating"); 
} the else { 
               Alert ( "home instant noodles"); 
} 
}    
function name (arguments);

Third, there is no return value parameter

function function value () { 
                  the console.log (); // which value does not print 
                  return '';
                   return '';
 //                               If the function returns a value, using a function, the value obtained is a function of the return. 
//                 hit return, to terminate execution of the function, a function can have only one return. 
} 

//             only return when they could print out the result of the function, otherwise undefined

Fourth, there is a return value parameters

function function value (parameter) {
                        return (parameters); 
} 
Document. write (function value (parameter));

 

Guess you like

Origin www.cnblogs.com/H5lcy/p/H5lcypxy.html