Use of Comparison Operator in JavaScript

In this article I have described about the comparison operator used in JavaScript.
  • 2227

JavaScript Operator - Comparison Operator

JavaScript comparison operator is used for comparison between two operands.

Lets take an example

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript Comparison Operator</title>
</head>
<body>

<h2>we have value of x is 100 compare it with x!=200</h2>
<button onclick="myFunction()"><b>lets check </b></button>
<h2 id="demo"></h2>
<script type="text/javascript">
function myFunction() {
var x =100;
document.getElementById("demo").innerHTML = x !=200;
}
</script>
</body>
</html>

 

Output


cmp optr.gif

Comparison Operator

The table having some comparison operator

   Operator         Description       Example
== equal to x == y
! = not equal to x != y
< less than x < y
> greater than x > y  
<= less then and equal to x <= y
>= greater than and equal to x>=y

Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.