Using literals like true
, 0
, and false
on either side of a logical operator is unnecessary.
For example, true && something
will always evaluate to something
.
If you're using ||
to set defaults (like num || 10
),
use the ??
operator instead (num ?? 10
).
const makesNoSense = someFunc() && true
const value = getValue() || 'default'
const thisIsFine = someFunc()
const value = getValue() ?? 'default'