How to use OR condition in a JavaScript IF statement?

JavascriptWeb DevelopmentFront End Technology

To use OR condition in JavaScript IF statement, use the || operator i.e Logical OR operator. If any of the two operands are non-zero, then the condition becomes true.

Here’s how you can use the operator || in JavaScript

Example

Live Demo

<html>
   <body>
      <script>
         var a = true;
         var b = false;

         document.write("(a || b) => ");
         result = (a || b);
         document.write(result);
      </script>
   </body>
</html>
raja
Published on 24-Jan-2018 06:07:23
Advertisements