ECMAScript logical operators

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>js逻辑运算符</title>
</head>
<body>
<script>
// 逻辑与&&
// alert(1&&1);//1
// alert(1&&0);//0
// alert(0&&1);//0
// alert(0&&0);//0
// 逻辑或||
// alert(1||1);//1
// alert(1||0);//1
// alert(0||1);//1
// alert(0||0);//0
// 逻辑非 !
// var a=1;
// if(a<10 && a>0){
// ++a;
// alert(a);2 // // if two operands are both objects, the second object is returned// If an operand is an object, the other operand is boolean, the object is returned
//}


// If an operand is null, then return null
// if the operand is a NaN, then returns NaN3
// If an operand is undefined, undefined return
// Alert (to false && O); to false
// Alert (to true && O); to true
// Alert (O && to true); to true
// Alert (O && to false); to false
// Alert (to true && null); null
// Alert (null && to true); null
// Alert (to true && NaN3); NaN3
// Alert (NaN3 && to true ); NaN3
// Alert (null && NaN3); null
// Alert (NaN3 && null); NaN3
// Alert (undefined && to true); undefined
// Alert (to true && undefined); undefined
// Alert (to false && undefined); to false
// Alert (undefined && to false); undefined

</ Script>

</body>
</html>

Guess you like

Origin www.cnblogs.com/startl/p/12231750.html