loading...
markdown guide
 

WAT

That's all there is to say about those things... See this brilliant talk:

destroyallsoftware.com/talks/wat

 

Try with this too:

  • [1] - 0
  • [1] + 1
  • [1] - 1
  • [1, 2] - 0
  • 1 + {}
  • [1] + {}
 
  1. I Suspected but got wrong.
  2. I got it right
  3. Never expected that to happen
  4. Obviously i expected
 

Wrong on the first one, definitly not expected that.

 
 

My answers, 50%:

  1. [{}] // Wrong
  2. [0] // Wrong
  3. 1 // Right
  4. 0 // Right
 
 

The + operator can either concatenate two elements or perform an addition.

In the first case, it will convert both elements to strings, the array being an empty string and the second one being [Object object].

Second does pretty much the same thing, [] = '', 0 = '0', '' + '0' = '0'
And the others are similar.

Classic DEV Post from Jun 27 '19

Jack Of All Trades or Master of One?

That age old question: how many pies should one have a thumb in?

Sai gowtham profile image
JavaScript developer, Blogger & Serverless

Do you prefer sans serif over serif?

You can change your font preferences in the "misc" section of your settings. ❤️