JavaScript Quiz Part 3

If you miss the part 1 and part 2 check out part1,part2

  1. [ ]+{ }

  2. [ ]+0

  3. { }+1

  4. [ ]-0

Did you find this post useful? Show some love!

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] + {}
Ben Halpern DEV.TO FOUNDER

Hey there, we see you aren't signed in. (Yes you, the reader. This is a fake comment.)

Please consider creating an account on dev.to. It literally takes a few seconds and we'd appreciate the support so much. ❤️

Plus, no fake comments when you're signed in. 🙃

  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

How does this happen? Can anyone explain? :O

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 Oct 20 '17

What developers want in a job

A look at what job-seekers value most when looking for a job.

READ POST
Follow @lynnetye to see more of their posts in your feed.
dev.to is now open source!
View Announcement Post View GitHub Repo
Sai gowtham
JavaScript developer, Writer & Serverless
More from @saigowthamr
How to Build Your Own Html editor⁉
#html #javascript #css #beginners
Music Player Using Reactjs
#react #javascript #webdev #beginners
Trending on dev.to
Exposing localhost server to the internet in one minute
#webdev #beginners #testing #devtips
I Failed as a Developer. And so did you.
#opensource #career #webdev #discuss
Leaving the Old Ways - jQuery vs React
#javascript #react #jquery #softwaredevelopment
Explain Hashing + salting Like I'm Five
#explainlikeimfive #webdev
My Favorite Free Resources for New Programmers
#beginners #learntocode #javascript #python
The Best Cross-Browser Testing Tools
#testing #selenium #devops #javascript
Building a Simple URL Shortener With Just HTML and Javascript
#urlshortener #javascript #html
Using feature flags for client demos and simulating complex scenarios
#javascript #showdev #reactnative