XVal operators
Truthyness and falsyness
Falsey
Truthy
false
true
0
All other numbers
""
empty-string
All other strings
null
()
unit-symbol
All list values
All object values
If-then-else operator
Short circuit operators
The ||
and &&
operators are truthy based value short circuit operators.
a && b
returns a
if a is falsey, or b
if a is truthy.
a || b
returns a
if a is truthy, or b
if a is falsy. This can be used for boolean logic (price < 100 && quantity < 3), for value selection based on conditions (price < 100 && ‘cheap’ || ‘expensive’), or for value coalescing (nickname || fullname).
Last updated
Was this helpful?