- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What types of logical operators are in javascript?
Logical Operators
Logic operators are used to find the logic between variables in JavaScript.There are three logical operators in JavaScript: || (OR), && (AND), ! (NOT).
The AND operator
The AND operator (&&) returns true if both expressions are true, otherwise it returns false.
Example
<html> <body> <p id="and"></p> <script> var a = 200; var b = 300; document.getElementById("and").innerHTML = (a > 100 && b <500) + "<br>" + (a < 100 && b <50); </script> </body> </html>
Output
true false
The OR operator
The OR operator gives value true if one or both expressions are true.
Example
<html> <body> <p id="or"></p> <script> var x = 200; var y = 300; document.getElementById("or").innerHTML = (x == 200 || y == 300) + "<br>" + (x == 200 || y == 0) + "<br>" + (x == 0 || y == 0) </script> </body> </html>
Output
true true false
The NOT operator
The NOT operator gives false for true values and true for false values.
Example
<html> <body> <p id="not"></p> <script> var x = 200; var y = 300; document.getElementById("not").innerHTML = !(x < y) + "<br>" + !(x > y); </script> </body> </html>
Output
false true
- Related Articles
- What are Logical Operators in JavaScript?
- What are the logical operators in Java?
- What are the logical operators in C#?
- Logical Operators in C++
- Python Logical Operators
- Java Logical Operators
- Perl Logical Operators
- Written version of Logical operators in C++
- What are operators in JavaScript?
- What are different Identity operators types in Python?
- What are different assignment operators types in Python?
- What are different bitwise operators types in Python?
- What are the differences between bitwise and logical AND operators in C/C++
- What are JavaScript Operators
- Relational and Logical Operators in C

Advertisements