JavaScript Logical Operators

You are Here:

JavaScript Logical Operators

The logical operators returns a boolean value by determining the logic between the values.

And Operator

And Operator returns true only if both the condition in the LHS and RHS are true. Otherwise it returns false.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 5; var num2 = 3; document.write(num1 < 10 && num2 < 10); </script> </body> </html>

JavaScript Logical Operators

The following are the list of logical operators available in JavaScript.

OperatorExplanationOperationResult
&&and(5 < 10 && 3 < 10)true
||or(5 < 10 || 3 > 10)true
!not!(5 > 3)false

OR Operator

OR Operator returns true if any of the conditions in the LHS or RHS is true. Otherwise it returns false.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 5; var num2 = 3; document.write(num1 < 10 || num2 > 10); </script> </body> </html>

Not Operator

Not Operator reverses the logic of a result.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 5; var num2 = 3; document.write(!(num1 > num2)); </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author