does javascript equality for 2.0 === 2 - hold true for all browsers

207 views Asked by At

I want to write a function to trim additional decimal 0's from floating point numbers like 2.0, 5.00 but not 3.04.

so I wrote this:

const trimZeroFromDecimal = value =>
  parseInt(value) === value ? parseInt(value) : value;

but will this equality between 2.0 and 2 hold true in all javascript environments - or are there any quirks to it?

Thanks for your help

0

There are 0 answers