I apologize in advance because this is somehow a silly question, but I just need to know WHY this happens and I didn't find the answer. So, there you go, stack overflow!
In this video (which I can't recommend enough) around 2:00 mark the guys shows that in Javascript:
[] + [] = empty string
[] + {} = object
{} + [] = 0
{} + {} = NaN
Anyone knows why?
This blog post by Adam Iley covers the reasoning behind most of those edge cases.
(Note: The site is having some database problems. You can use the google cache until they fix things.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With