Training 0531

Today talked about three aspects

A determining

Two, three expressions

Third, circulation

Fourth, the function

details as follows:

1.if judgment

(1) if (condition) { 

      } When statement execution condition is satisfied

if the constraint condition determination

if ( "undefined") {// conditions are converted into Boolean
the console.log ( "nengshuchu " )
}

2. a triplet of expressions (trinocular operation, ternary operator)

if a simplified version

grammar:

? 1 expression represented by Formula 2: 3 Expression;
/ conditions (Boolean)
to true when the expression 2 down
to false when walking Expression 3
var = 100 A;
A == 100 the console.log ( "Hello")? : console.log ( "bad");

3. Cycle

Within the conditions, repeat to execute a section of code

for,for in,foreach,forof,while,dowhile

for (Condition 1; Condition 2; Condition 3; {

Circulation of statements}

break; exit the loop

continue; this cycle out

for(var i=0;i<10;i++){

console.log(i);

When if (i == 5) {condition is satisfied when

break; just met, the cycle is ended

}

}

4. Functions

Function: the package code, the code is a set of

Like naming convention rules and variables: function name

Parameters: parameter (formal parameters), the type parameter may be limited, the number may not be limited

Function body: Code function is called when the execution of

return: the return value, if not written, undefined is returned

function function name (parameter 1, parameter 2 ...) {

Function body

} Return return value of the function

 

Guess you like

Origin www.cnblogs.com/tokki-zhan159/p/10956418.html