HTML and CSS Reference
In-Depth Information
side evaluates to true, and the right side is false, the expression is false. If evaluated as
Booleans, the same rules apply, except the returned value will be either Boolean true or
false . See Table 5.12.
Table 5.12 Logical AND Examples
Expression
What It Evaluates To
true && false
false
true && true
true
"honest" && true
true
true && ""
(empty string)
true && "honest"
honest
5 && 0
0
5 && -6
-6
5 && false
false
null && 0
null
null && ""
null
null && false
null
"hello" && true && 50
50
"this" && "that"
that
EXAMPLE 5.8
<html>
<head>
<title>Logical AND Operator</title>
</head>
<body bgcolor="lightblue">
<big>
<script type="text/javascript">
1
var answer = prompt("How old are you? ", "");
2
if (answer > 12 && answer < 20) {
alert("Teenagers rock!");
}
</script>
</big>
</body>
</html>
Search WWH ::




Custom Search