How to compare two numbers in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To compare two numbers in JavaScript, use the == operator. You can try to run the following code to compare numbers −

Example

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <script>
         var a = 10;
         var b = 20 ;
         if(a == b) {
            document.write("True");
         }else {
            document.write("False");
         }
      </script>
   </body>
</html>

Output

false
raja
Published on 03-Feb-2018 17:20:58
Advertisements