JS: Boolean Operators

By Xah Lee. Date: . Last updated: .
x && y
and operator. Return true if both Boolean(x) and Boolean(y) are true, else false. If Boolean(x) is false, y is not evaluated. 〔see Boolean Constructor
// “and” operator
console.log(true && true);
x || y
or operator. Return true if one of Boolean(x) or Boolean(y) is true, else return false. If Boolean(x) is true, y is not evaluated. 〔see Boolean Constructor
// “or” operator
console.log(true || true);
!x
not operator. Reverse the boolean value. Return true if Boolean(x) is false, return false if Boolean(x) is true. 〔see Boolean Constructor
// “logical negation” operator
console.log(!false);

JavaScript, Operators