Logic, predicates and sets#
Booleans and conditionals#
Compare with ==, !=, <, <=, >, and >=. Combine with and, or, xor, and not. Choose a result with condition ? yes : no.
(3 > 1) and (3 < 5)
not false
true ? 10 : 20Interactive examples could not load. You can still copy the expressions.
The named comparison functions such as equal, larger, and smallerEq are the function form of the same operators, and deepEqual compares nested contents. Given an array, a comparison may return an array of booleans rather than one boolean.
Predicates and special values#
isFinite, isNaN, isInteger, isNumeric, isNegative, isPositive, isZero, and hasNumericValue test values. Test NaN with isNaN, never with equality. nullish supplies an alternative for a null or undefined result.
Sets#
The set functions cover union, intersection, difference, symmetric difference, the Cartesian product, distinct values, size, multiplicity, subset tests, and the powerset. They take the array and matrix shapes listed in each reference.
setUnion([1, 2, 3, 4], [3, 4, 5, 6])Interactive examples could not load. You can still copy the expressions.
The bitwise functions (bitAnd and friends) operate on integer bits, which is a different thing from boolean logic.