The javascript comparison operators are used to compare operand. The following are some javascript comparison operators.
JS comparison operators
- "==": Equal to
- "!=": Not Equal
- "===": Equal and the same type(identical).
- "!==": Not identical.
- ">": Greater than.
- ">=": Greater than or equal to.
- "<": Greater than.
- "<=": Greater than or equal to.
Example: JS comparison operators
<!DOCTYPE html> <html> <head> </head> <body> <h3>JS comparison operators</h3> <p>If x=10; y=5; and z=5;</p> <p id="p1"></p> <p id="p2"></p> <p id="p3"></p> <p id="p4"></p> <p id="p5"></p> <p id="p6"></p> <p id="p7"></p> <p id="p8"></p> <script type="text/javascript"> let x=10; let y=5; let z=5; document.getElementById("p1").innerHTML= "x==z-->"+(x==z); document.getElementById("p2").innerHTML= "x!=y-->"+(x!==y); document.getElementById("p3").innerHTML= "x===z-->"+(x===z); document.getElementById("p4").innerHTML= "x!==z-->"+(x!==z); document.getElementById("p5").innerHTML= "x>y-->"+(x>y); document.getElementById("p6").innerHTML= "x>=z-->"+(x>=z); document.getElementById("p7").innerHTML= "x<=y-->"+(x<y); document.getElementById("p8").innerHTML= "x<=z-->"+(x<=z); </script> </body> </html>
JS comparison operators
If x=10; y=5; and z=5;
0 Comments