javascript logical operators tutorial

JavaScript Logical Operators:

JavaScript logical operators are used to perform logical operations on the operands.

JavaScript Logical Operators List:

Operator Description Example
&& Logical AND (20==40 && 20==30) = false
|| Logical OR (20==40 || 20==30) = false
! Logical Not !(20==30) = true

JavaScript Arithmetic Operators Example:

<html>
<head>
<script type="text/javascript">
             var a = true;
            var b = false;
            var linebreak = "<br />";
 
            document.write("(a && b) => ");
            result = (a && b);
            document.write(result);
            document.write(linebreak);
 
            document.write("(a || b) => ");
            result = (a || b);
            document.write(result);
            document.write(linebreak);
 
            document.write("!(a && b) => ");
            result = (!(a && b));
            document.write(result);
            document.write(linebreak);        
      </script>
</head>
   <body>
   </body>
</html>

Try it:

JS Bin on jsbin.com