Logical Operators
These operations can be performed on boolean values.
Unary Operators
NOT (!)
Used to invert a boolean value; true values become false and false values become true.
- Knot
 - TypeScript
 
knotconst foo = true;const bar = false;!foo == false;!false == true;!(foo && bar) == true;
knotconst foo = true;const bar = false;!foo == false;!false == true;!(foo && bar) == true;
tsxconst foo = true;const bar = false;!foo === false;!false === true;!(foo && bar) === true;
tsxconst foo = true;const bar = false;!foo === false;!false === true;!(foo && bar) === true;
Binary Operators
AND (&&)
This operation evaluates to true if both the left-hand and right-hand expressions evaluate to true and false otherwise.
- Knot
 - TypeScript
 
knotconst foo = true;const bar = false;(foo && true) == true;(bar && true) == false;(bar && bar) == false;
knotconst foo = true;const bar = false;(foo && true) == true;(bar && true) == false;(bar && bar) == false;
tsxconst foo = true;const bar = false;(foo && true) === true;(bar && true) === false;(bar && bar) === false;
tsxconst foo = true;const bar = false;(foo && true) === true;(bar && true) === false;(bar && bar) === false;
OR (||)
This operation evaluates to true if either the left-hand or right-hand expressions evaluate to true and false otherwise.
- Knot
 - TypeScript
 
knotconst foo = true;const bar = false;(foo || true) == true;(bar || true) == true;(bar || bar) == false;
knotconst foo = true;const bar = false;(foo || true) == true;(bar || true) == true;(bar || bar) == false;
tsxconst foo = true;const bar = false;(foo || true) === true;(bar || true) === true;(bar || bar) === false;
tsxconst foo = true;const bar = false;(foo || true) === true;(bar || true) === true;(bar || bar) === false;