What is Logical OR Operator (||) in JavaScript?

JavascriptWeb DevelopmentFront End Technology

The operator || is the logical OR operator. If any of the two operands are non-zero, then the condition becomes true.

Example

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

<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 19-Jan-2018 05:19:49
Advertisements