🚧logical operator
🚧 under construction -> example
JS ⟩ statement ⟩ expression ⟩ operator ⟩ logical ⟩
a && b
:returnsa
ifa
is falsy, otherwise returnsb
.a || b
:returnsa
ifa
is truthy, otherwise returnsb
.a ?? b
:returnsa
ifa
is non-nullish, otherwise returnsb
.!a
:returnsfalse
ifa
is truthy, otherwise returnstrue
.
&&
and||
can do short-circuiting.unlike
&&
and||
,!
always returns true or false.
Last updated