The comparison operator

// var a = 1>2; // document.write(a); Var a = "">"; // document.write(a);Copy the code

Second, the logical operators && | |! Three operators

The && operator example
// var a = 1 && 2;
// document.write(a);
Copy the code

1. && the preceding expression is converted to a Boolean if true, then the result of the second Boolean is looked at, if false, return the value of that expression, if both are true, return the last // to false stop

/ / case

// var a = 1 && 2 + 2 && 0;
// document.write(a);
Copy the code

/ / case

// var a = 1 && 2 && 0 && 1;
// document.write(a);
Copy the code

// The short circuit statement does not care about the return value

// 2 > 1 && document.write(" I like you ");Copy the code
2. Or the operator | |

If the first expression is true, return the first expression; If it is false, search for truth later and return the value, if all false, return the last // to true stop

/ / case

// var a = 0 || 1 || 5;
// document.write(a);
Copy the code

/ / case

// div. Onclick = function (e) {// var event = e;Copy the code

In [IE browser does not work, there is nothing in e, there is window.event], so use the following formula to express, compatible

// var event = e || window.event;
Copy the code
3. Non-operators!

Convert to a Boolean value and take the six values of false: undefined /null /NaN/””/0 /false

// var a =!" "; // document.write(a); // var a = !!" "; // document.write(a);Copy the code