Camparison Operator



Write a JavaScript code to illustrate comparison operators.

<html>
  <head>
    <title>Comparison Operator</title>
      <script>
        var a = 5, b = 10, c ="5";

            document.write ("a == c =" + (a == c)); // returns true 
            document.write ("<br>");

            document.write ("a === c =" + (a === c)); // returns false
            document.write ("<br>");

            document.write ("a == 5 =" + (a == 5)); // returns true
            document.write ("<br>");

            document.write ("a != b =" + (a != b)); // returns true
            document.write ("<br>");

            document.write ("a > b =" + (a > b)); // returns false
            document.write ("<br>");

            document.write ("a < b =" + (a < b)); // returns true
            document.write ("<br>");

            document.write ("a >= b =" + (a >= b)); // returns false
            document.write ("<br>");

            document.write ("a <= b =" + (a <= b)); // returns true
            document.write ("<br>");

            document.write ("a >= c =" + (a >= c)); // returns true
            document.write ("<br>");

            document.write ("a <= c =" + (a <= c)); // returns true

      </script>
    </head>
  <body>       
</body>
</html>

Output:

a == c =true
a === c =false
a == 5 =true
a != b =true
a > b =false
a < b =true
a >= b =false
a <= b =true
a >= c =true
a <= c =true