Logical Operators
&& operator: The "and" operator tests the first expression and if it evaluates to false, then return false. If the first expression evaluates to true, returns the value of the second expression. So, if either expression is false, then it will return false. If both expressions are true, then it will return true.
|| operator: The "or" operator test the first expression and if it evaluates to true, then it returns true. If it evaluates to false, then it returns the value of the second expression. So, if either expression is true, it will return true. If neither expression is true, it will return false.
If the first expression of an || operator evaluates to true, then the second expression will not be evaluated and true will be the result of the expression;
If the first expression of an && operator evaluates to false, then the second expression will not be evaluated and false will be the result of the expression.
! operator: The "not" operator returns false if the single operand evaluates to true, otherwise return false;
Last updated
Was this helpful?