What are boolean operators?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What are boolean operators?
Rating:
The boolean operators are used to check more than one condition at a time. There are situations where the JavaScript programmers have to evaluate two or more conditions and the result is based on the result of all the conditions.
There are three kinds of boolean operators as follows:
- &&
- ||
- !
In the case of the && operator, the result is true only if all the conditions are true. In the given conditions, if a condition is false, the result will be false.
The following table shows the result of evaluating two conditions:
| True | && | True | True |
| True | && | False | False |
| False | && | True | False |
| False | && | False | False |
In the case of the || operator, the result is false only if both the conditions are false. Otherwise, the result is true.
The following table shows the result of the or operator:
| | | ||
| True | || | True | True |
| True | || | False | True |
| False | || | True | True |
| False | || | False | False |
In the case of the not operator, if the condition is not false, it is true. If the condition is not true, it is false
The following table shows the result of the not operator:
| | | |
| True | ! | False |
| False | ! | True |
Rating:
Was this information helpful?
Other articles
- Functions, Global Functions, and Custom Objects.
- How are cookie files stored in different browsers?
- What is the Math object?
- How to create a function in JavaScript?
- What is client-side scripting?
