A falsy value is a value that is considered false when encountered in a Boolean context.


JavaScript uses Type Conversion to coerce any value to a Boolean in contexts that require it, such as conditionals and loops.


There are only 6 falsy values in JavaScript

This means that when JavaScript is expecting a boolean and it is given one of the values below, it will always evaluate to “falsy”

false The keyword false
0 The number zero.

BigInt, when used as a boolean, follows the same rule as a Number. 0n is falsy.

"", '', ``

This is an empty string(the length of the string is zero).

Strings in JavaScript can be defined with double quotes "", or single quotes '', as well as Template literals ``

null null  - the absence of any object value
undefined undefined - the primitive value
NaN NaN - not a number




Examples of falsy values in JavaScript (which are coerced to false in Boolean contexts, and thus bypass the if block):

if (false)
if (null)
if (undefined)
if (0)
if (0n)
if (NaN)
if ('')
if ("")
if (``)
if (document.all)


The logical AND operator, &&

If the first object is falsy, it returns that object

let pet = false && "dog";

// ↪ false


document.all has been used for browser detection in the past and the HTML specification defines a willful violation of the ECMAScript standard here to keep compatibility with legacy code (if (document.all) { // Internet Explorer code here(except IE11) } or using document.all without checking its presence first: document.all.foo).

Sometimes written falsey, although in English usually turning a word into an adjective with a -y, any final e is dropped (noise => noisy, ice => icy, shine => shiny)

Learn more

Document Tags and Contributors

Last updated by: sideshowbarker,