[JS] Falsy Values

About

A falsy (or falsey) value is a value that's considred false when encountered in a Boolean context.

Falsy Values in JavaScript

ValueDescription

false

The keyword false.

0

The Number zero (so, also 0.0, etc., and 0x0).

-0

The Number negative zero (so, also -0.0, etc., and -0x0).

0n

The BigInt zero (so, also 0x0n). Noe that there is no BigInt negative zero -- the negation of 0n is 0n.

"", '', ``

Empty string value.

null -- the absence of any value.

undefined -- the primitive value.

NaN -- not a number.

Objects are falsy if and only if they have the [[IsHTMLDDA]] internal slot. That slot only exists in document.all and cannot be set using JavaScript.

REF

Last updated