Empty Array
suggest change/* ToNumber(ToPrimitive([])) == ToNumber(false) */
[] == false; // true
[].toString() calls [].join(), which returns "". ToNumber("") and ToNumber(false) are both 0, so [] == false is true.
An array is an object. Ordinary objects are truthy, so [] is truthy in a condition. In browsers, document.all is the legacy object that is falsy.
// Internally this is evaluated as ToBoolean([]) === true ? 'truthy' : 'falsy'
[] ? 'truthy' : 'falsy'; // 'truthy'
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents