Member-only story
JavaScript Booleans: Is Falsy Actually False?
An in-depth look into the eight falsy values

JavaScript booleans are notoriously tricky. Even seasoned programmers fail to get them right from time to time. They are one of the major pitfalls in the JavaScript language. This article takes a deep dive into JavaScript booleans and what you can do to understand them better.
true is not false, or is it?
The reason, I think, many JavaScript developers have such problems with booleans is the fact that JavaScript English differs from plain English. In spoken English: if something is not true, then it’s false. That goes without exception. In JavaScript, however, this is not always the case. This difference is something that confuses JavaScript programmers and especially those new to the language.
One of the fundamentals of most programming languages, including JavaScript, is that you read code similar to how you would say it out loud. But, as JavaScript has an ambiguous definition of true and false, the way you read the code can easily fool you. It is unfortunate, but it’s not unexpected. Programming languages evolve over time, and just like spoken languages, they contain irregularities and exceptions.
To tackle this ambiguity, JavaScript introduces the concept of truthy and falsy values. These are essential to the JavaScript language, and you use them even when you speak (about) JavaScript. So to master JavaScript, you need to fluently know when to use truthy/falsy and when to use true/false.
The Eight Falsy Values
There are eight falsy values in JavaScript. Three of them are variations of the number zero. The variants are the positive, the negative, and the BigInt type of the value zero. People sometimes refer to them as six as they consider all the zero values as one. Regardless of which, a JavaScript developer should learn them by heart. For more info on these, refer to the MDN falsy or truthy documentation. The eight falsy values are:
// The eight falsy valuesconst theValueFalse = false;
const theNumberZero = 0;
const theNegativeNumberZero = -0;
const theBigIntZero = 0n;
const anEmptyString = '';
const theNullObject = null;
const…