Introduction
When reading articles about JavaScript, you might run into the terms truthy
and falsy
. In this post I will explain what they are and show how to remember which values are truthy
and which are falsy
.
Truthy
A truthy is a value which when evaluated in the context of a Boolean evaluates to true
.
Falsy
A falsy is a value which when evaluated in the context of a Boolean evaluates to false
.
How to know which values are truthy and which are falsy?
There are 8 values which are falsy: 0, false, null, undefined, 0n, NaN (Not a Number), -0 and “”. Any values other than those are considered truthy
values.