JavaScript in && | | The difference
&& | | When the operator is not on either side of a Boolean type, the system is converted to a Boolean type value for recalculation (an empty string, NULL, 0 will be turned to false), and the result itself will not change.
&& operator Summary: As long as a false to take the value of false, all is true take the back, is false take the front.
<script type= "Text/javascript" >var a = 123 && 234;var b = 0 && 1;var c = 1 && 0;var d = 1 &A mp;& "", var e = "" "&& 1;var f =" "&& 0;var g = 0 &&" "; Console.log (a); Output result: 234console.log (b); Output Result: 0console.log (c); Output result: 0console.log (d); Output: "" Console.log (e); Output: "" Console.log (f); Output: "" Console.log (g); Output result:0</script>
|| Operator Summary: As long as a value of true takes true, all is true to take the front, all false take the back.
<script type= "Text/javascript" >var a = 123 | | 234; Output result: 123var b = 0 | | 1; Output result: 1var c = 1 | | 0; Output result: 1var D = 1 | | ""; Output: 1var e = "" | | 1; Output: 1var f = "" | | 0; Output: 1var g = 0 | | ""; Output: 0console.log (a); Console.log (b); Console.log (c); Console.log (d); Console.log (e); Console.log (f); Console.log ( g);</script>
The two operators need to be aware that only one side is false and true, and both are false or true.
JavaScript in && | | The difference