Analyzing Js cycle

One,

Analyzing
// ternary expressions with
// loop
@ determination: if the most is determined by the
// 1.
{// if (condition)
statement is executed when the condition is satisfied after the //
//}

// 2.
// if (condition) {
//
// the else {}
// if the above conditions are not met when left under
//}

// 3. Analyzing multiple conditions
// if (condition) {
//
// the else iF} (condition) {
//
//} the else if (condition) {
//
// the else {}
//
//}

// if a group is determined, if only one, ELSEIF can have zero or more
// else there can be only 0 or 1


A = to true var;
if (A) {// This last condition will all be converted to Boolean
the console.log ( "Hello");
} {the else
the console.log ( "World");
}

// set if a determination the future face of current conditions is met, execution will not go back

 

two,

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

// do 1. When comparing with NAN
@ 2 is converted into digital type false 0 non-0 converted to true
// math
// false is converted to 0
// true is converted to 1
// 0 converted to false, non-zero transformed into true What does it mean?
// 3. an empty string into false, non-idle into true
// 4. all types of reference conversion to true
plus or minus 5. Do not write // decimal condition if the determination (key key)

// if the determination
// 0, false, empty string , undefined, null is converted to false. all other converts to true


// typeof () method of detection data type, to be detected on the type of the parameter
values returned by @: Number String Boolean function Object undefind

// var A = 10;
// var B = "Hello World";
// var = C [];
// D var = {};
// function E () {};
// var F = null;
// var G;
// the console.log (typeof (G))
// IF (undefined ) {
// the console.log ( "this can output it?")
//}
// 0.1 + 0.2 = 0.3
the console.log (0.1 + 0.2); // in any one of the high-level language, this is called the number of precision
IF (0.1 + 0.2 == 0.3) {
the console.log ( "Nice !!!")
}

 

 

three,

A triplet of expressions
// three head operation
// ternary operator

// simple point to understand is that if a simplified version
// syntax
// expression is a group of Formula 2:? Expression 3;
// condition (boolean)
// to true when walking expressions 2
// false expression when walking 3
// var a = 100;
// a == 100 console.log ( "Hello"):? console.log ( "bad");


// receive user input wages
// is equal to 1. If the salary is greater than 20,000 outputs "Tyrant"
// is equal to 2. If the salary is greater than 8,000 is less than 20,000, the output of "general"
// 3. If the salary is less than 8,000, the output "Cock wire"
/ / ternary expression is complete, you can not use IF
var a = prompt ( "Please enter your wage:");
a> = 20000 Alert ( "Tyrant"): a> = 8000 alert ( " general"):?? alert ( "grass root");

 

 

four,

cycle

 

Console output
// console.log ();
// alert box output
// Alert ()
// page output
// document.write (); // write a piece of content in the document, the content is a string of format

document.write ( "Hello");
// also prints a html code, this code can be parsed html browsers
document.write ( '<h1 of class = "COLOR_RED"> aksjdfhlsjkdf </ h1 of>');
// quotes nesting problem

// Loop: repeat a section of code to execute in a range of conditions.
// for, for in, the foreach, forof, the while, DoWhile
// for (Condition 1; Condition 2; 3 condition) {
// cycle statements
// }
// A ++
// A. 1 = A +
// for (var A = 0; A <. 5; A ++) {// increase their ++. 1
// the console.log ( "Hello")
//}
//. 1 . var a = 0; <b > satisfy <5 </ b>; a + 1 -> execution cycle statements inside
// 2. a = 1; satisfy <5; a + 1 -> inside the execution cycle statement
// 3. a = 2; satisfy <5; a + 1 -> execution cycle statements inside
// 4. a = 3; satisfy <5; a + 1 -> execution cycle statements inside
// 5 . a = 4; satisfy <5; a + 1 -> execution cycle statements inside
// 6. a = 5; not satisfied <5 cycle has ended



@ + from 1 100
// 1 + 2 + 3 + .... + + 99 +4 100;
var NUM = 0;
for (var. 1 = I; I <= 100; I ++) {
the console.log (I);
NUM = NUM + I;
}
Console.People (num);

 

Fives,

break; exit loop
// continue; this cycle out
// for (var I = 0; I <10; I ++) {
// the console.log (I);
// IF (I ==. 5) {// when when conditions are met.
@ BREAK; // just met, the end of the cycle directly
//}
//}


for (var I = 0; I <10; I ++) {
IF (I ==. 5) {
Continue; // this cycle out
}
the console.log (I);
}

 

 

six,

<title> function </ title>
</ head>
<body>
<Script>
// Function: the package code, is a set of code
// function name: Naming same rules as variables
// parameters: shape parameter (formal parameters), the type parameter may be limited, the number may not be limited
// function body: when the code when the function is executed by calling
// return: return value, if not written, undefined is returned
// function function name (parameter 1, parameter 2 ...) {
//// function body
//
// return the return value
//}


function Fun () {
return to true
}
the console.log (Fun ()) // the return value is output to perform the function of the output function
// console nothing? because the function has not yet begun to call

// function how to call?
// console.log (Fun) Fun says that a function
// () to perform symbolic execution is a function

// built-in functions
// isNaN () returns a boolean
// typeof ()
// parseInt ()
// parseFloat ()
// Alert ()
// eval ()
// ...

Guess you like

Origin www.cnblogs.com/xmm520/p/10957014.html