JavaScript: Logic Operators

By Xah Lee. Date: .
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

BUY
ΣJS
JavaScript in Depth

JavaScript in Depth

Basic Syntax

Value Types

Variable

String

Property

Object and Inheritance

Array

Function

Constructor/Class

Iterable 🌟

Misc