How to use OR condition in a JavaScript IF statement?

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


Live Demo

         var a = true;
         var b = false;

         document.write("(a || b) => ");
         result = (a || b);

Updated on: 19-Sep-2019

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started