A falsy value is a value that translates to false when evaluated in a Boolean context.

JavaScript uses type coercion in Boolean contexts.

Examples of falsy values in JavaScript (which translate to false and thus bypass the if block):

if (false)
if (null)
if (undefined)
if (0)
if (NaN)
if ('')
if (document.all) [1]

[1] 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 } or using document.all without checking its presence first: document.all.foo).

Learn more

Document Tags and Contributors

Contributors to this page: Andrew_Pfeiffer, hbloomer, klez, fscholz
Last updated by: Andrew_Pfeiffer,