<script type= "Text/javascript" >
/******************************************************************* implementing IfElse expressions with operator precedence
result = expression1 && expression2
Result is true when and only if the value of two expressions equals true.
If the value of either expression equals false, the result is false.
JScript uses the following rules to convert a non-Boolean value to a Boolean value:
All objects are considered true.
The string is considered false when and only if it is empty.
Null and undefined are considered false.
The number is false if and only if it is zero.
*******************************************************************/
alert (1&&0); False,return the first false ' s argument 0
alert (1&&2); True,return the last true ' s argument 2
/*******************************************************************
result = Expression1 | | Expression2
If one or two of the two expressions equals true, result is true.
JScript uses the following rules to convert non-Boolean values to Boolean values:
All objects are considered true.
The string is considered false when and only if it is empty.
Null and undefined are considered false.
The number is false if and only if it is 0 o'clock.
*******************************************************************/
Alert (1| | 0); True,return the first ture ' s argument 1
Alert (0| | FALSE); False,return the last false ' argument false
/*******************************************************************
A "side-by-side" expression that returns the last expression
*******************************************************************/
Alert ((1,0,-1)); Return the last Argument-1
/*******************************************************************
Use operator precedence to implement if (...) {...} Else{...}
The return value of the undefined is not clear.
Undefined,null will be converted to false.
*******************************************************************/
var a = true;
A && (alert (' true '), 1) | | Alert (' false ')
/*******************************************************************
Or use the three-mesh operator
*******************************************************************/
A? Alert (' True '): Alert (' false ');
</script>
JavaScript uses the and OR operator precedence to implement an if else condition judgment expression