LOGICAL OPERATORS
Logical operators can also be used in conditional statements. The logical operators return a Boolean value -- in other words, true or false. The logical operators are shown in the following table.
| Logical Operator | Description |
|
&&
|
AND |
|
||
|
OR |
|
!
|
NOT |
Using logical operators, you can combine conditions in an if
statement; for example:
if (fName == "Fred" && lName == "Astaire") {
tName = fName + " " + lName;
alert("Welcome, " + tName);
}
This if statement tests both the first condition and the second
condition, and executes the code block if both conditions are true.
