Writing JavaScript with Only Six Characters
javascript.christmas
javascript.christmas
Maybe you could do a kind of proof:
1. This is how you get any character 2. This is how you call eval() 3. QED
The unary plus operator coerces undefined to NaN, not to zero as your article states.
The unary plus operator coerces NaN to NaN, not to zero as your article states. (Remember that NaN is already a number, despite its name.)
If you need to coerce any falsy value to 0, the simplest way is to use bitwise operators. If you want to do it the six character way, I guess use Math.imul
It quickly gets more complicated though, and will require alot more code:
"undefined": [][![]]+[] (empty array accessed at index 0 turned into string)
"NaN": +{}
"[object Object][object Object]": {}+{}
.. etc
See the full list here: