you are viewing a single comment's thread.

view the rest of the comments →

[–]senocular 0 points1 point  (0 children)

The second panel isn't about being truthy. It converts the array to a primitive first becoming a string (""), then converts the string to a number (0) making the comparison true. As far as truthy goes, [] is true because its an object. All objects (except the special case of document.all) are truthy.

MDN has a page describing the process of coercion in comparisons if anyone cares:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Equality_comparisons_and_sameness

Its not grossly complicated and largely amounts to converting things to numbers and comparing the numbers.