From http://www.sitepoint.com/javascript-truthy-falsy/

The following values are always falsy:

  • false
  • 0 (zero)
  • 0n (BigInt zero)
  • "" (empty string)
  • null
  • undefined
  • NaN (a special Number value meaning Not-a-Number!)

All other values are truthy, including "0" (zero in quotes), "false" (false in quotes), empty functions, empty arrays ([]), and empty objects ({}).

Regarding why this is so, I suspect it's because JavaScript arrays are just a particular type of object. Treating arrays specially would require extra overhead to test Array.isArray(). Also, it would probably be confusing if true arrays behaved differently from other array-like objects in this context, while making all array-like objects behave the same would be even more expensive.

Answer from Barmar on Stack Overflow
🌐
DEV Community
dev.to › naftalimurgor › truthy-and-falsy-values-in-javascript-458p
Truthy and Falsy values in JavaScript - DEV Community
June 5, 2022 - JavaScript treats the following values as Truthy: true - A boolean of value true · {} value of an object with no properties, declared using Object literal · [] an empty array · 51 any non-zero number, including negative and positive numbers ...
🌐
Reddit
reddit.com › r/frontend › javascript wtf: why does every() return true for empty arrays? - human who codes
r/Frontend on Reddit: JavaScript WTF: Why does every() return true for empty arrays? - Human Who Codes
November 14, 2023 - The author, Nicholas C. Zakas, clarifies that every() assumes a true result by default and only returns false if any element in the array fails the provided test. This behavior aligns with the mathematical concept of vacuous truth, where a statement ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › why-do-empty-javascript-arrays-evaluate-to-true-in-conditional-structures
Why do Empty JavaScript Arrays Evaluate to True in Conditional Structures? - GeeksforGeeks
August 12, 2024 - Empty arrays in JavaScript are evaluated to be true in conditional structures because arrays are objects, and all objects are considered truthy in JavaScript. This can sometimes lead to confusion, especially when we expect an empty array to be false.
🌐
Jsonlogic
jsonlogic.com › truthy.html
Truthy and Falsy
Because JsonLogic rules need to ... truthy and what is falsy. For example, in PHP, empty arrays are falsy, but in JavaScript arrays are always truthy....
🌐
Trevor Lasn
trevorlasn.com › home › blog › javascript truthy and falsy values: complete reference
JavaScript Truthy and Falsy Values: Complete Reference
November 1, 2024 - 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 string. That empty string then converts to 0, and 0 == false is true.
🌐
ServiceNow Community
servicenow.com › community › developer-forum › falsy-and-truthy-and-empty-arrays-in-servicenow-javascript › m-p › 3353036
Falsy and Truthy and empty arrays in ServiceNow Javascript
August 16, 2025 - Despite appearing wrong, from a pure JavaScript perspective (as an array is always Truthy according to the Javascript Specification), it worked perfectly! It should have been... if (someArray && someArray.length ) { doSomething(); } Why didn't I need to change it?
🌐
Sololearn
sololearn.com › en › Discuss › 1638302 › why-is-empty-array-or-list-falsey-in-python-but-truthy-in-javascript
Why is [] (empty Array or list) falsey in Python but, truthy in JavaScript? | Sololearn: Learn to code for FREE!
I'm having a little confusion about "emptyness" of lists and Arrays When I do: console.log(!![]); // then, it logs "true" but, when I do: print(not not []) // it print "False" ??? But, why these two languages have different implementation of the same concept? Is there any logic behind their implementation or are Arrays different from lists? javascriptpythonlistsarraysimplementationlogical-operators ... From the official docs (https://docs.python.org/3/library/stdtypes.html#truth-value-testing): Truth Value Testing¶ Any object can be tested for truth value, for use in an if or while condition or as operand of the Boolean operations below.
Find elsewhere
🌐
CodePen
codepen.io › arosenb2 › post › is-a-javascript-empty-array-falsey-or-not
Is A JavaScript Empty Array Falsey Or Not? by Aaron on CodePen
While testing some new code at Experience, I noticed what feels like an inconsistency in array to boolean conversions in JavaScript. To prove the difference, here are the situations I looked at: // Straight Equality [] == true; // false [] == false; // true // Conversion Boolean([]); // true ! Boolean([]); // false // Implied Conversion ! []; // false !! []; // true · As you can see, the first straight equality checks behave as if an empty array is false, which is common in back end languages, such as Groovy.
🌐
Medium
medium.com › coding-in-simple-english › what-are-truthy-values-in-javascript-e037bdfa76f8
What are truthy values in JavaScript? | by Dr. Derek Austin 🥳 | Coding in Simple English | Medium
January 4, 2023 - Values not on the list of falsy values in JavaScript are called truthy values and include the empty array [] or the empty object {}.
🌐
Ash Allen Design
ashallendesign.co.uk › blog › how-to-check-if-an-array-is-empty-in-javascript
How to Check If an Array Is Empty in JavaScript
January 8, 2024 - If the array is not empty, the length property will return an integer greater than 0 (which is truthy), so the expression will return false like so: ... Similar to the previous approach, there are some caveats to using this approach, and we'll ...
🌐
Holy
blog.holy.kiwi › js › 180515
🍉 In JS, is an empty Array return false or true? - blog.holy.kiwi
Because Array is type of object, the fact that an empty Array is conversed to true is correct.
🌐
Reddit
reddit.com › r/javascript › javascript wtf: why does every() return true for empty arrays?
r/javascript on Reddit: JavaScript WTF: Why does every() return true for empty arrays?
September 5, 2024 - The operation for the "every()" method is "&&", and the identity is "true" (true && x == x). That's why the result for an empty array is "true". Conversely, the "some()" method uses the "||" operation, and the identity is "false" (false || x ...
🌐
GoLinuxCloud
golinuxcloud.com › home › javascript › 6 methods to check if array is empty in javascript
6 Methods to check if Array is Empty in JavaScript | GoLinuxCloud
April 15, 2024 - An empty array is treated as truthy in JavaScript, however !arr.length takes advantage of the fact that 0 is falsy which makes this condition true for empty arrays.
🌐
LinkedIn
linkedin.com › pulse › mastering-truthy-falsy-values-javascript-key-efficient-mohammed-osman
Mastering Truthy and Falsy Values in JavaScript: A Key to Efficient Coding and Avoiding Pitfalls
May 28, 2023 - A truthy value is one that is considered true when evaluated in this context. Conversely, a falsy value is considered false. JavaScript defines six falsy values: false, 0, '' (empty string), null, undefined, and NaN.
Top answer
1 of 10
311

You're testing different things here.

if (arr) called on object (Array is instance of Object in JS) will check if the object is present, and returns true/false.

When you call if (arr == false) you compare values of this object and the primitive false value. Internally, arr.toString() is called, which returns an empty string "".

This is because toString called on Array returns Array.join(), and empty string is one of falsy values in JavaScript.

2 of 10
70

Regarding the line:

if (arr == false) console.log("It's false!");

Maybe these will help:

console.log(0 == false) // true
console.log([] == 0) // true
console.log([] == "") // true

What I believe is happening is that the boolean false is coerced to 0 for comparison with an object (the left-hand side). The object is coerced to a string (the empty string). Then, the empty string is coerced into a number, as well, namely zero. And so the final comparison is 0 == 0, which is true.

Edit: See this section of the spec for details on exactly how this works.

Here's what's happening, starting at rule #1:

1. If Type(x) is different from Type(y), go to step 14.

The next rule that applies is #19:

19. If Type(y) is Boolean, return the result of the comparison x == ToNumber(y).

The result of ToNumber(false) is 0, so we now have:

[] == 0

Again, rule #1 tells us to jump to step #14, but the next step that actually applies is #21:

21. If Type(x) is Object and Type(y) is either String or Number, return the result of the comparison ToPrimitive(x)== y.

The result of ToPrimitive([]) is the empty string, so we now have:

"" == 0

Again, rule #1 tells us to jump to step #14, but the next step that actually applies is #17:

17. If Type(x) is String and Type(y) is Number, return the result of the comparison ToNumber(x)== y.

The result of ToNumber("") is 0, which leaves us with:

0 == 0

Now, both values have the same type, so the steps continue from #1 until #7, which says:

7. If x is the same number value as y, return true.

So, we return true.

In brief:

ToNumber(ToPrimitive([])) == ToNumber(false)
🌐
Codementor
codementor.io › community › how to avoid common pitfalls in javascript
How to Avoid Common Pitfalls in JavaScript | Codementor
January 18, 2017 - Isn't that supposed to be false, since empty arrays are truthy? That's right but the double equal operator evaluates expressions on certain rules. We're trying to compare an object with a boolean value and JavaScript will implicitly convert the operands to Number type.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › truthy-in-javascript
Truthy In JavaScript - GeeksforGeeks
July 23, 2025 - An empty object is truthy! Objects with properties are truthy! Similarly, all arrays (including empty arrays []) are truthy.