DEV Community


Posted on

Twenty-second article! An important difference between parseInt and + in javascript

I'll be brief!

  • parseInt('.3', 10)
    • returns NaN
  • +'.3'
    • returns 0.3 (a Number)

The + operator might be slower than parseInt, but it's a bit more intuitive imo... and my goodness the title was almost as long as the article itself.

Top comments (0)