Falsey values in JavaScript

  • false
  • Zero of Number type: 0 and also -0, 0.0, and hex form 0x0 (thanks RBT)
  • Zero of BigInt type: 0n and 0x0n (new in 2020, thanks GetMeARemoteJob)
  • "", '' and `` - strings of length 0
  • null
  • undefined
  • NaN
  • document.all (in HTML browsers only)
    • This is a weird one. document.all is a falsey object, with typeof as undefined. It was a Microsoft-proprietory function in IE before IE11, and was added to the HTML spec as a "willful violation of the JavaScript specification" so that sites written for IE wouldn't break on trying to access, for example, document.all.something; it's falsy because if (document.all) used to be a popular way to detect IE, before conditional comments. See Why is document.all falsy? for details

"Falsey" simply means that JavaScript's internal ToBoolean function returns false. ToBoolean underlies !value, value ? ... : ...; and if (value). Here's its official specification (2020 working draft) (the only changes since the very first ECMAscript specification in 1997 are the addition of ES6's Symbols, which are always truthy, and BigInt, mentioned above:

Argument type Result
Undefined Return false.
Null Return false.
Boolean Return argument.
Number If argument is +0, -0, or NaN, return false; otherwise return true.
String If argument is the empty String (its length is zero), return false; otherwise return true.
BigInt If argument is 0n, return false; otherwise return true.
Symbol Return true.
Object Return true.

Comparisons with == (loose equality)

It's worth talking about falsy values' loose comparisons with ==, which uses ToNumber() and can cause some confusion due to the underlying differences. They effectively form three groups:

  • false, 0, -0, "", '' all match each other with ==
    • e.g. false == "", '' == 0 and therefore 4/2 - 2 == 'some string'.slice(11);
  • null, undefined match with ==
    • e.g. null == undefined but undefined != false
    • It's also worth mentioning that while typeof null returns 'object', null is not an object, this is a longstanding bug/quirk that was not fixed in order to maintain compatibility. It's not a true object, and objects are truthy (except for that "wilful violation" document.all when Javascript is implemented in HTML)
  • NaN doesn't match anything, with == or ===, not even itself
    • e.g. NaN != NaN, NaN !== NaN, NaN != false, NaN != null

With "strict equality" (===), there are no such groupings. Only false === false.

This is one of the reasons why many developers and many style guides (e.g. standardjs) prefer === and almost never use ==.


Truthy values that actually == false

"Truthy" simply means that JavaScript's internal ToBoolean function returns true. A quirk of Javascript to be aware of (and another good reason to prefer === over ==): it is possible for a value to be truthy (ToBoolean returns true), but also == false.

You might think if (value && value == false) alert('Huh?') is a logical impossibility that couldn't happen, but it will, for:

  • "0" and '0' - they're non-empty strings, which are truthy, but Javascript's == matches numbers with equivalent strings (e.g. 42 == "42"). Since 0 == false, if "0" == 0, "0" == false.
  • new Number(0) and new Boolean(false) - they're objects, which are truthy, but == sees their values, which == false.
  • 0 .toExponential(); - an object with a numerical value equivalent to 0
  • Any similar constructions that give you a false-equaling value wrapped in a type that is truthy
  • [], [[]] and [0] (thanks cloudfeet for the JavaScript Equality Table link)

Some more truthy values

These are just a few values that some people might expect to be falsey, but are actually truthy.

  • -1 and all non-zero negative numbers

  • ' ', " ", "false", 'null'... all non-empty strings, including strings that are just whitespace

  • Anything from typeof, which always returns a non-empty string, for example:

    • typeof null (returns a string 'object' due to a longstanding bug/quirk)
    • typeof undefined (returns a string 'undefined')
  • Any object (except that "wilful violation" document.all in browsers). Remember that null isn't really an object, despite typeof suggesting otherwise. Examples:

    • {}
    • []
    • function(){} or () => {} (any function, including empty functions)
    • Error and any instance of Error
    • Any regular expression
    • Anything created with new (including new Number(0) and new Boolean(false))
  • Any Symbol

true, 1, "1" and [1] return true when compared to each other with ==.

Answer from user56reinstatemonica8 on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Falsy
Falsy - Glossary | MDN
July 11, 2025 - A falsy (sometimes written falsey) 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.
🌐
SamanthaMing
samanthaming.com › tidbits › 25-js-essentials-falsy-values
JS Essentials: Falsy Values | SamanthaMing.com
JS values have an inherent associated boolean value to it. Knowing which values evaluate to true or false, is important for comparisons & conditionals...
Discussions

What are truthy and falsy values in javascript?
Doesn't include symbols. And I guess true and false were implied but would be nice to see listed with the rest. More on reddit.com
🌐 r/learnjavascript
11
3
May 2, 2019
javascript - Falsy values vs null, undefined, or empty string - Software Engineering Stack Exchange
I've worked with jQuery over the years. However, recently, I've found myself getting deeper into the JavaScript language. Recently, I've heard about "truthy" and falsey values. However, I don't fully More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
When does “&&” returns the first falsy value and when does it return a boolean on JS?
I don't know if I understand what are boolean and non-boolean values This one is easy: there are exactly two boolean values in JS: true and false. These are actual keywords in JavaScript (and many other languages), and they are the only two actual boolean values that exist. Literally anything else is a non-boolean value. Some operators such as the comparison operators (>, <, >=, <=...) will always return a boolean value, because the answer is either true or false. As to the rest of the question, check out the docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_AND The logical AND (&&) operator (logical conjunction) for a set of operands is true if and only if all of its operands are true. It is typically used with Boolean (logical) values. When it is, it returns a Boolean value. However, the && operator actually returns the value of one of the specified operands, so if this operator is used with non-Boolean values, it will return a non-Boolean value. What this actually means is that it always returns the first "falsy" value, if any exist, including false. It always tries to short-circuit. If the first falsy value it encounters is false, then it returns false. If it's falsy but not the actual boolean false value, it returns the falsy value. If it never encounters a falsy value, it returns the last truthy value, which could be true or a truthy value. So, in this example you provided: var isALarge = (a > b) && (a > c); // false, it returns a boolean a > b results in either true or false. Same for a > c. So, it first evaluates the left-hand side. a > b is 1 > 2, which evaluates to false. The evaluation stops there, due to short-circuiting logic and the second comparison is never even made. It knows that one of the operands is falsy (and actually false here), so it returns it immediately. It's honestly a bit confusing, coming from other languages where you can't compare non-boolean values with boolean values, to be sure. Edit: as a bit of bonus information, the same applies to the logical or operator || , but flipped. It will return the first truthy value it finds (and short-circuit that way), or the last provided falsy value. More on reddit.com
🌐 r/learnprogramming
13
1
October 20, 2021
I can’t for the life of me understand “truthy” and “falsey” values in an example I found in the book “ATBS”
Python is dynamic and will have automatic type-conversion where possible - letter you do things like combine strings with numbers without needing to convert. Truthiness/falsiness is like this but for booleans - the language has to decide how to convert types into booleans. It probably all comes from C which has no boolean type but by convention 0 is considered false. So if 0 is false then a number is false if it's 0 but otherwise its true. From there you get a string of length 0 being false, otherwise true. More on reddit.com
🌐 r/learnprogramming
19
3
September 25, 2023
Top answer
1 of 4
456

Falsey values in JavaScript

  • false
  • Zero of Number type: 0 and also -0, 0.0, and hex form 0x0 (thanks RBT)
  • Zero of BigInt type: 0n and 0x0n (new in 2020, thanks GetMeARemoteJob)
  • "", '' and `` - strings of length 0
  • null
  • undefined
  • NaN
  • document.all (in HTML browsers only)
    • This is a weird one. document.all is a falsey object, with typeof as undefined. It was a Microsoft-proprietory function in IE before IE11, and was added to the HTML spec as a "willful violation of the JavaScript specification" so that sites written for IE wouldn't break on trying to access, for example, document.all.something; it's falsy because if (document.all) used to be a popular way to detect IE, before conditional comments. See Why is document.all falsy? for details

"Falsey" simply means that JavaScript's internal ToBoolean function returns false. ToBoolean underlies !value, value ? ... : ...; and if (value). Here's its official specification (2020 working draft) (the only changes since the very first ECMAscript specification in 1997 are the addition of ES6's Symbols, which are always truthy, and BigInt, mentioned above:

Argument type Result
Undefined Return false.
Null Return false.
Boolean Return argument.
Number If argument is +0, -0, or NaN, return false; otherwise return true.
String If argument is the empty String (its length is zero), return false; otherwise return true.
BigInt If argument is 0n, return false; otherwise return true.
Symbol Return true.
Object Return true.

Comparisons with == (loose equality)

It's worth talking about falsy values' loose comparisons with ==, which uses ToNumber() and can cause some confusion due to the underlying differences. They effectively form three groups:

  • false, 0, -0, "", '' all match each other with ==
    • e.g. false == "", '' == 0 and therefore 4/2 - 2 == 'some string'.slice(11);
  • null, undefined match with ==
    • e.g. null == undefined but undefined != false
    • It's also worth mentioning that while typeof null returns 'object', null is not an object, this is a longstanding bug/quirk that was not fixed in order to maintain compatibility. It's not a true object, and objects are truthy (except for that "wilful violation" document.all when Javascript is implemented in HTML)
  • NaN doesn't match anything, with == or ===, not even itself
    • e.g. NaN != NaN, NaN !== NaN, NaN != false, NaN != null

With "strict equality" (===), there are no such groupings. Only false === false.

This is one of the reasons why many developers and many style guides (e.g. standardjs) prefer === and almost never use ==.


Truthy values that actually == false

"Truthy" simply means that JavaScript's internal ToBoolean function returns true. A quirk of Javascript to be aware of (and another good reason to prefer === over ==): it is possible for a value to be truthy (ToBoolean returns true), but also == false.

You might think if (value && value == false) alert('Huh?') is a logical impossibility that couldn't happen, but it will, for:

  • "0" and '0' - they're non-empty strings, which are truthy, but Javascript's == matches numbers with equivalent strings (e.g. 42 == "42"). Since 0 == false, if "0" == 0, "0" == false.
  • new Number(0) and new Boolean(false) - they're objects, which are truthy, but == sees their values, which == false.
  • 0 .toExponential(); - an object with a numerical value equivalent to 0
  • Any similar constructions that give you a false-equaling value wrapped in a type that is truthy
  • [], [[]] and [0] (thanks cloudfeet for the JavaScript Equality Table link)

Some more truthy values

These are just a few values that some people might expect to be falsey, but are actually truthy.

  • -1 and all non-zero negative numbers

  • ' ', " ", "false", 'null'... all non-empty strings, including strings that are just whitespace

  • Anything from typeof, which always returns a non-empty string, for example:

    • typeof null (returns a string 'object' due to a longstanding bug/quirk)
    • typeof undefined (returns a string 'undefined')
  • Any object (except that "wilful violation" document.all in browsers). Remember that null isn't really an object, despite typeof suggesting otherwise. Examples:

    • {}
    • []
    • function(){} or () => {} (any function, including empty functions)
    • Error and any instance of Error
    • Any regular expression
    • Anything created with new (including new Number(0) and new Boolean(false))
  • Any Symbol

true, 1, "1" and [1] return true when compared to each other with ==.

2 of 4
4

Don't forget about the non-empty string "false" which evaluates to true

🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › falsy
What is "Falsy" in JavaScript? - Mastering JS
October 28, 2019 - In JavaScript, a value is falsy if JavaScript's built-in type coercion converts it to false.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Glossary › Truthy
Truthy - Glossary | MDN
November 13, 2025 - That is, all values are truthy except false, 0, -0, 0n, "", null, undefined, NaN, and document.all. JavaScript uses type coercion in Boolean contexts.
🌐
freeCodeCamp
freecodecamp.org › news › falsy-values-in-javascript
Falsy Values in JavaScript
December 14, 2019 - Description A falsy value is something which evaluates to FALSE, for instance when checking a variable. There are only six falsey values in JavaScript: undefined, null, NaN, 0, "" (empty string), and false of course. Checking for falsy values ...
Find elsewhere
🌐
Reddit
reddit.com › r/learnjavascript › what are truthy and falsy values in javascript?
r/learnjavascript on Reddit: What are truthy and falsy values in javascript?
May 2, 2019 - Questions and posts about frontend development in general are welcome, as are all posts pertaining to JavaScript on the backend. ... Doesn't include symbols. And I guess true and false were implied but would be nice to see listed with the rest. ... I'm getting the vibe that this article evaluates to 'meh'. ... Same. It was also clearly basically Google translated, which shows some pretty intense laziness. Based on this value, the program takes decision in `if and else` statements.
🌐
freeCodeCamp
freecodecamp.org › news › what-are-falsey-values-in-javascript
What are Falsy Values in JavaScript? Explained with Examples
April 2, 2025 - In JavaScript, every value has a boolean equivalent. This means it can either be evaluated as true (truthy value) or false (falsy value) when used in a boolean context. But what is a boolean context? It's a situation where a boolean value is expected...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › falsy-in-javascript
Falsy in JavaScript - GeeksforGeeks
July 23, 2025 - In JavaScript, falsy values are those that are evaluated as false when used in a Boolean.
🌐
DEV Community
dev.to › alwaysaman › understanding-truthy-falsy-values-in-javascript-the-art-of-conditional-logic-33l9
Understanding Truthy & Falsy Values in JavaScript: The Art of Conditional Logic 🎭 - DEV Community
October 6, 2024 - In JavaScript, truthy and falsy values determine how a value behaves in a conditional statement. Some values are automatically considered true, while others are automatically considered false.
🌐
Trevor Lasn
trevorlasn.com › home › blog › javascript truthy and falsy values: complete reference
JavaScript Truthy and Falsy Values: Complete Reference
November 1, 2024 - The empty array comparison [] == false evaluates to true, yet an empty array is actually truthy. This happens because JavaScript first converts the array to a primitive value. When an empty array is converted to a primitive, it becomes an empty ...
🌐
SitePoint
sitepoint.com › blog › javascript › truthy and falsy values: when all is not equal in javascript
Truthy and Falsy Values: When All is Not Equal in JavaScript — SitePoint
November 11, 2024 - Seemingly different values equate to true when compared with == (loose or abstract equality) because JavaScript (effectively) converts each to a string representation before comparison: ... A more obvious false result occurs when comparing with === (strict equality) because the type is considered:
Top answer
1 of 5
24

In programming, truthiness or falsiness is that quality of those boolean expressions which don't resolve to an actual boolean value, but which nevertheless get interpreted as a boolean result.

In the case of C, any expression that evaluates to zero is interpreted to be false. In Javascript, the expression value in

if(value) {
}

will evaluate to true if value is not:

null
undefined
NaN
empty string ("")
0
false

See Also
Is there a standard function to check for null, undefined, or blank variables in JavaScript?

2 of 5
9

The set of "truthy" and "falsey" values in JavaScript comes from the ToBoolean abstract operation defined in the ECMAScript spec, which is used when coercing a value to a boolean:

+--------------------------------------------------------------------------+
| Argument Type | Result                                                   |
|---------------+----------------------------------------------------------|
| Undefined     | false                                                    |
|---------------+----------------------------------------------------------|
| Null          | false                                                    |
|---------------+----------------------------------------------------------|
| Boolean       | The result equals the input argument (no conversion).    |
|---------------+----------------------------------------------------------|
| Number        | The result is false if the argument is +0, −0, or NaN;   |
|               | otherwise the result is true.                            |
|---------------+----------------------------------------------------------|
| String        | The result is false if the argument is the empty String  |
|               | (its length is zero); otherwise the result is true.      |
|---------------+----------------------------------------------------------|
| Object        | true                                                     |
+--------------------------------------------------------------------------+

From this table, we can see that null and undefined are both coerced to false in a boolean context. However, your fields.length === 0 does not map generally onto a false value. If fields.length is a string, then it will be treated as false (because a zero-length string is false), but if it is an object (including an array) it will coerce to true.

If fields should be a string, then !fields is a sufficient predicate. If fields is an array, your best check might be:

if (!fields || fields.length === 0)
🌐
Medium
medium.com › @nehatanwar.dev › understanding-truthy-and-falsy-values-in-javascript-b1e18f01f3b5
Understanding Truthy and Falsy Values in JavaScript | by Nehatanwar | Medium
January 11, 2025 - Falsy values are values that, when evaluated in a boolean context, behave as false. These values are: ... In other words, if you use any of these values in an if or else statement, JavaScript will consider them as false.
🌐
DEV Community
dev.to › myogeshchavan97 › javascript-basics-truthy-and-falsy-values-in-javascript-4jo2
JavaScript Basics: Truthy and Falsy values in JavaScript - DEV Community
April 26, 2021 - Truthy and Falsy values are the non-boolean values that are coerced to true or false when performing certain operations.
🌐
ServiceNow Community
servicenow.com › community › developer-articles › checking-truthy-falsy › ta-p › 2321458
Checking truthy/falsy - ServiceNow Community
August 22, 2020 - From time to time the need arises to check if a value exists. Not if it's explicitly this or that rather, whether the value "exists" or not. In JS when a value is evaluated in a condition, the result is said to be either: true or false. A true or false evaluate is known as either truthy or falsy.
🌐
Zipy
zipy.ai › blog › truthy-and-falsy-values-in-javascript
truthy and falsy values in javascript
April 12, 2024 - Falsy values are those that evaluate to false when converted to a Boolean, while truthy values evaluate to true. Debug and fix code errors with Zipy Error Monitoring. ... JavaScript defines a specific set of values as falsy, and memorizing this ...