Baseball bat
This is first time when variable name isn’t a:
let baseball_bat = 0;
baseball_bat += 0==[[[[[[]]]]]] // BONK! baseball_bat = 1Explanation
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 == 0will returntrue. In the end, addingtrueis similar to adding 1 (still not the best idea).