Way2tutorial Snippet Editor
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript Logical Operators</title> </head> <body> <pre> <!-- Use pre element for work document.writeln() method --> <script type="text/javascript"> document.writeln("AND : ", (5 == 5) && (10 == 10)); // Returns true document.writeln("AND : ", true && false); // Returns false document.writeln("OR : ", (5 == 5) || (5 == 10)); // Returns true document.writeln("OR : ", true || false); // Returns true document.writeln("AND : ", 5 && 10); // Returns 10 document.writeln("OR : ", 5 || 10); // Returns 5 document.writeln("NOT : ", !5); // Returns false document.writeln("NOT : ", !true); // Returns false document.writeln("NOT : ", !false); // Returns true </script> </pre> </body> </html>