JavaScript Weirdness
I was just listening to the lightning talk by Gary Bernhardt from CodeMash 2012 and he brought up some really interesting (and funny) points about JavaScript.
For example:
[] + [];
””
{} + {};
NaN
[] + {};
[object Object]
{} + [];
0
So why is it that if you add two empty Arrays you get an empty string, but if you add two objects you get “not a number”. Array + Object is an Object but Object plus Array is 0???
1 Notes/ Hide
-
together12up liked this
-
registrar8uir liked this
-
keynotetis8 liked this
-
edanhewitt reblogged this from nathanfirth
-
nathanfirth posted this