3 ms·
Great use of JavaScript's weird + operator. The whole trick stems from the fact that !$ == false and !$+$ == "false"
by loganlinn 16y ago
Great use of JavaScript's weird + operator.
The whole trick stems from the fact that !$ == false and !$+$ == "false"
- weixiyen 16y agovar $ = [] ![] == false because [] exists. false + [] == 'false' because anything added to an array will become whatever that is as a string plus the contents inside the array. 2 + [] is also a string "2" 2 + [2,2] will become "22,2" (string)
- hencq 16y agoWow, I knew the + operator was weird, but didn't realise it allowed you to do stuff like that. What I don't get though, wouldn't you still need to call eval() on it to do anything with it? Or does javascript do a 'implied eval' when you try to call a string?