3 ms·
Somebody hasn't seen "wat". https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
by rcfox 14y ago
Somebody hasn't seen "wat". https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- 1_player 14y agoGod, that was fun
- Hupo 14y agoThe fun thing about JavaScript's type coercion and concatenation is that you can use it to create fun brain benders like this: +[[+!+[[]]]+[![]][+[[]+[]]]++] === 10 This evaluates to true. Cookie for anyone who can explain why!
- spoiler 14y agoI gues it could be because + infront of an empty array returns 0. So, when you do !+[] you get 1. What you pasted it a bit of a labyrinth, but if someone bothered to keep track of it, they could definitely find ten 1s in there. It's not why, it's a how. I hope someone figures out the rest and gets a cookie! :D
- spoiler 14y agoOh, I've seen it, but it didn't cross my mind. However, I knew before that Array + <something> will give you a String (with the members of that array delimited by a comma) followed by <something> cast into a String. I don't find that wat. Also, the reason why String+Number works is because + is overridden on strings to concatenate, while - isn't. That's why you get a NaN, but you probably know that. How would you expect it to work anyway? I don't think it's that watty. The only thing that I find wat-worthy is Object + <something>, because that truly makes little sense. There might be some ambiguous logic behind it, though.