1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>javascript逻辑与</title> 9<! -8 Logic (&&) personal understanding: 10 Prerequisites: . 11 - Logic and sequence determination: from left to right; 12 is - as long as encountered false / null / undefined / NaN down will not determined. A first direct return false / null / undefined value / NaN of 13 is - full really true returns the last value 14 1) Boolean operands are 15 full true: Returns to true 16 . 1 false or false: returns false 17 number 2) operable to mix multiple types (expression, and other Boolean type) 18 is a fake / false multi / full false: returns the first prosthesis 19 all true: returns the last true 20 is 3) special case: operands is null / undefined / NaN 21 is just containing null / undefined / NaN, it will return null / undefined / NaN; 22 is if null / undefined / NaN exist, the first null / undefined / NaN is returned. 23 is -> 24 </ head > 25 < body > 26 is < Script > 27 var A = 10 , B = " 10 " , C = 20 is , D = "" , E = 0 , F = " dd " , G; 28 / * logic: boolean * / 29 the console.log (A == B && A < C); // to true 30 the console.log (A == B && A > C); // to false 31 is / * logic: Mixed * / 32 the console.log (e && A); // 0, the first operand e false, or first, E 33 is the console.log (a && D); // "", a true first operand, the second return, D 34 is the console.log (a && B && C); // 20 is, a \ b \ c are true, returns the last, C 35 the console.log (a && D && E); // "", a true, d false, false E, a first return false, d = "" 36 console.log(a && B && C); // 20 is, all true, and finally returns a true 37 [ the console.log ( null && A && B && C); // null 38 is the console.log ((A - F) && A && B); // NaN3 39 the console.log (G && A && B); // undefined 40 the console.log (NaN3 && null && defined); // NaN3, who was the first of these three who returned 41 </script> 42 </body> 43 </html>