Page 298 - Web Applications (803) Class 11
P. 298

<      less than        It is used to check whether any expression generates   x<8        false
                                           a value less than other expressions; if so, then the
                                           value would evaluate to true; else false.

                   >=     greater than or   It is used to check whether the left operand is greater   x>=8   true
                          equal to         than or equal to the right operand.

                   <=     less than or     It is used to check whether the left operand is less   x<=8       true
                          equal to         than or equal to the right operand.
                  ===     Triple Equals    It is used to compare the equality of two operands   x===”8”      false
                                           with a data type. If both the value and the data type
                                           are equal, then the condition is true, otherwise false.

              Let us create a JavaScript program to use comparison operators.

              <!DOCTYPE html>
              <HTML>
              <HEAD>
                <TITLE>JavaScript Comparison Operators </TITLE>
              </HEAD>
              <BODY>
                <H1>Performing Comparison Operations </H1>
                <SCRIPT>
                var a = 12, b = 4;
                document.write("a = " + a + ", b = " + b + "<br>");
                document.write("Result of " + a +" greater than " + b +" is = " + (a > b) + "<br>");
                 document.write("Result of " + a +" greater than or equal to " + b +" is = " + (a >= b)
                 + "<br>");
                 document.write("Result of " + a +" less than or equal to " + b +" is = " + (a <= b) +
                 "<br>");
                document.write("Result of " + a +" less than " + b +" is = " + (a < b) + "<br>");
                document.write("Result of " + a +" equal to " + b +" is = " + (a ==b ) + "<br>");
                document.write("Result of " + a +" not equal to " + b +" is = " + (a !=b ) + "<br>");
              </SCRIPT>
              </BODY>
              </HTML>























                296     Touchpad Web Applications-XI
   293   294   295   296   297   298   299   300   301   302   303