1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title></title>6 7 <Scripttype= "Text/javascript">8 9 /*Ten * && | | non-boolean value case One * A *-When a non-Boolean value is evaluated and or operated, it is converted to a Boolean value and then evaluated, and the original value is returned - * - *-with Operation: the *-If the first value is true, then a second value must be returned - *-If the first value is false, the first value is returned directly - * - *-or arithmetic + *-If the first value is true, the first value is returned directly - *-Returns a second value if the first value is False + * A */ at - //true && true - //and operations: If two values are true, then return to the back, who returns behind who - varresult= 5 && 6; - Console.log ("result ="+result); //6 - in - //and operation: If there is a false in two values, the forward false is returned to //false && True + result= 0 && 2; - Console.log ("result ="+result); //0 the * result= 2 && 0; $ Console.log ("result ="+result); //0Panax Notoginseng - the //false && false + result=NaN&& 0; A result= 0 &&NaN; the Console.log ("result ="+result); //0 + - //----------------------------------------------------------------------------- $ $ //true | | true - //if the first value is true, the first value is returned directly - result= 2 || 1; the Console.log ("result ="+result); //2 - Wuyi result= 2 ||NaN; the Console.log ("result ="+result); //2 - Wu result= 2 || 0; - Console.log ("result ="+result); //2 About $ - //if the first value is false, the second value is returned directly - result=NaN|| 1; - Console.log ("result ="+result); //1 A + result=NaN|| 0; the Console.log ("result ="+result); //0 - $ result= "" || "Hello"; the Console.log ("result ="+result); //Hello the the result= -1 || "Hello"; the Console.log ("result ="+result); //-1 - in the </Script> the About </Head> the <Body> the </Body> the </HTML>
JS Base _ Non-Boolean value and OR operation