back

by tobr·8y ago·view on hn ↗
That’s a terrible idea:

  parseInt(0.000001) // 0
  parseInt(0.0000001) // 1
1 comments
For anyone who is wondering why:

parseInt() only accepts strings as input. So JavaScript calls .toString() on the number before passing it as an argument.

    (0.000001).toString() // "0.000001"
    (0.0000001).toString() // "1e-7"
By the way, TypeScript or Flow would have caught this error during compile time.