JavaScript Comparison Operators

You are Here:

JavaScript Comparison Operators

The comparison operators enable you to test conditions.

The comparison operator is also called as relational operator.

Equal To Operator

Equal To operator is used to check whether the given values are equal irrespective of its type.

Example

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

JavaScript Comparison Operators

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

OperatorExplanationOperationResult
==equal to5 == "5"true
===strict equal to5 === "5"false
!=not equal to5 != "5"false
!==strict not equal to5 !== "5"true
>greater than5 > 3true
<less than5 < 3false
>=greater than or equal to5 >= 5true
<=less than or equal to5 <= 5true

Strict Equal To Operator

Strict Equal To operator is used to check whether the given values are equal with respect to its type.

Example

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

Not Equal To Operator

Not Equal To operator is used to check whether the given values are not equal irrespective of its type.

Example

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

Strict Not Equal To Operator

Strict Not Equal To operator is used to check whether the given values are not equal with respect to its type.

Example

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

Greater Than Operator

Greater Than operator is used to check whether the first value is greater than the second value.

Example

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

Lesser Than Operator

Lesser Than operator is used to check whether the first value is lesser than the second value.

Example

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

Greater Than or Equal To Operator

Greater Than or Equal To operator is used to check whether the first value is greater than or equal to the second value.

Example

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

Greater Than or Equal To Operator

Greater Than or Equal To operator is used to check whether the first value is greater than or equal to the second value.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 5; var num2 = 5; 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