JavaScript Operator: logical AND
[this page | pdf | back links]
In JavaScript,
the && operator is
the logical (i.e. Boolean) AND operator:
x
|
y
|
x AND y
|
true
|
true
|
true
|
true
|
false
|
false
|
false
|
true
|
false
|
false
|
false
|
false
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>table,th,tr,td {border: 1px solid black;
border-collapse: collapse;}</style>
</head>
<body>
<table>
<tr>
<th>x</th><th>y</th>
<th>Resulting value of <code>x AND y</code></th>
</tr>
<tr>
<td><code>true</code></td><td><code>true</code></td>
<td><code id="TrueTrue"></code></td>
</tr>
<tr>
<td><code>true</code></td><td><code>false</code></td>
<td><code id="TrueFalse"></code></td>
</tr>
<tr>
<tr>
<td><code>false</code></td><td><code>true</code></td>
<td><code id="FalseTrue"></code></td>
</tr>
<tr>
<td><code>false</code></td><td><code>false</code></td>
<td><code id="FalseFalse"></code></td>
</tr>
</table>
<script>
document.getElementById("TrueTrue").innerHTML = true && true;
document.getElementById("TrueFalse").innerHTML = true && false;
document.getElementById("FalseTrue").innerHTML = false && true
document.getElementById("FalseFalse").innerHTML = false && false;
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript Operators