Do you know what will be the output of this code?
JavaScript
console.log(parseInt("08.9px"), Number("08.9px"));
Show answer and explanation
The answer is 8 NaN.
parseInt parses as far as it can and stops at ., so it returns 8. Number requires the whole string to be a valid number, and "px" makes it NaN.
See all the ways to convert a string to a number in JavaScript and when each one fits.