Comparison Operators demo - Javascript Operator

Javascript examples for Operator:Comparison Operators

Description

Comparison Operators demo

Demo Code

<!DOCTYPE html>/*from  w  ww .j a  v  a  2s . c  o  m*/
<html>
<body>
<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = 5;
    document.getElementById("demo").innerHTML = (x <= 8);
    
    document.getElementById("demo").innerHTML += " "+ (x == 5);
    
    document.getElementById("demo").innerHTML += " "+ (x === "5");

    document.getElementById("demo").innerHTML += " "+ (x === 5);
 
    document.getElementById("demo").innerHTML += " "+ (x != 8);

    document.getElementById("demo").innerHTML += " "+ (x !== "5");

    document.getElementById("demo").innerHTML += " "+ (x !== 5);
 
    document.getElementById("demo").innerHTML += " "+ (x > 8);

    document.getElementById("demo").innerHTML += " "+ (x < 8);

    document.getElementById("demo").innerHTML += " "+ (x >= 8);

    document.getElementById("demo").innerHTML += " "+ (x <= 8);

Related Tutorials