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:
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
If you found this post helpful, please consider supporting my work financially:☕️Buy me a coffee!