NOT operator !
inverts truthy and falsy values. Truthy values become false, and falsy values become true.
Use the NOT operator to avoid else statements:
Double Negation
Double negation !!
converts values to boolean:
!!someVariable
It works by first converting a truthy value to false with !
, then back to true with another !
. It explicitly
casts values to true or false.