DEV Community

Discussion on: You should stop using `parseInt()`

Collapse
 
andreidascalu profile image
Andrei Dascalu

My point is mostly:

  • the performance comparison is moot because the functions discussed don't do the same thing
  • the correct way to formulate the use case for Number is: you should use Number when you want to extract the correct numeric value in full from a string AND you don't care about the resulting type.
  • use case for ParseInt: you want to ensure conversion to an integer OR the partial extraction of an integer (similar for float)