JavaScript · Middle · Question 35 of 75

What do parseInt('12px') and Number('12px') return?

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.

Further reading

Problem with a question

JavaScript · Middle · question 35

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz