Truthy values are values that can be coerced to
true in a Boolean context, like an
if statement. Falsy values are considered
false in a Boolean context. That means that a value is truthy if it causes an
if block or
while loop to execute, for example.
Truthy and Falsy Values
Truthy values are a little easier to remember: all values that are not falsy are truthy.
Here are some examples of truthy values:
"false", "0", and
If you're ever curious if a value is truthy or falsy, here's a short and simple function to help you out:
const isTruthyOrFalsy = (value) => value ? 'truthy' : 'falsy'
Simply put, truthy values are
true in a Boolean context and falsy values are