I countered this issue in my program, I have a string numStr
and I want to parse it as an integer
.
I tried both on node
and spider-monkey
environments.
What is the problem and how I fix it?
const numStr = '12360600901222567';
console.log(+numStr);
console.log(parseInt(numStr));
console.log(parseFloat(numStr));
console.log(Number(numStr));
Output:
12360600901222568
12360600901222568
12360600901222568
12360600901222568
Expected:
12360600901222567