Nathan Firth

  • Archive
  • RSS

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???

    • #javascript
    • #weirdness
  • 3 weeks ago
  • 1
  • Permalink
  • Share
    Tweet

1 Notes/ Hide

  1. together12up liked this
  2. registrar8uir liked this
  3. keynotetis8 liked this
  4. edanhewitt reblogged this from nathanfirth
  5. nathanfirth posted this
← Previous • Next →

About

I'm an internet entrepreneur, web developer, designer, lover of Jesus from San Diego. Originally from Sweden. I have a beautiful wife, and two amazing kids.
Follow @nathanfirth

loading tweets…

  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco but customized by Nathan Firth.

Powered by Tumblr