JavaScript Logical Operators
Notes:
JavaScript Logical Operators:
Logical operators are also known as logical connectives.
They are used to connect one or more conditions. They accept Boolean operands, on evaluation they yield the result true or false.
&&: Logical And Operator:
If both LHS and RHS operands are true then the result will be true, in all other cases the result will be false
||: Logical Or Operator:
If both LHS and RHS operands are false then the result will be false, in all other cases the result will be true
!: Logical Not Operator:
If the given operand is false, then the result will be true. Vice versa
document.write("Logical Operators");
document.write( (3<4) && (4<5) ); // true
document.write( (3>4) && (4<5) ); // false
document.write( (3>4) || (4>5) ); // false
document.write( (3<4) || (4>5) ); // true
document.write( !(3<4) ); //false
document.write( true && true ); // true
document.write( false || false ); // false
document.write( !(false) ); // true
document.write( ("Hello"=="Hello") && ("World"=="World") );//true
Interview Questions: