JavaScript · Middle · Question 35 of 75
What do parseInt('12px') and Number('12px') return?
- ✓Correct answer:
12andNaN - 2
NaNand12 - 3
12and12
Explanation
parseInt reads a number from the start of the string while it sees digits, while Number requires the whole string to be a number. Specify the radix: parseInt(str, 10). For decimals, use parseFloat.