parseInt(0.000001)
返回0
但
parseInt(0.0000001)
返回1
Does anyone happen to know the reason for this behaviour?
parseInt(0.000001)
返回0
但
parseInt(0.0000001)
返回1
If the number is greater than 1e+21 (including) or less than 1e-7 (including), it will return 1. (when using radix/base 10).个
例如:
console.log(parseInt(0.0000001));
console.log(parseInt(0.000000123));
console.log(parseInt(1e-7));
console.log(parseInt(1e+21));
签出MDN文档:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#examples个