Baseball bat
This is first time when variable name isn’t a
:
Explanation
Comparing 0 to this… array return 1. Let’s figure it out step-by-step:
- In the beginning we are trying to compare Number with Object.
You can find how it works in specification.
Array will be casted with
ToPrimitive()
operation and return""
.- Result will be same for
[]
,[[]]
,[[[]]]
, etc.
- Result will be same for
- In result, we have
"" == 0
. Now we visit specification again and find out that we need transform string withToNumber()
operation, and it will return 0. 0 == 0
will returntrue
. In the end, addingtrue
is similar to adding 1 (still not the best idea).