parseInt("123qwe")

returns 123

Number("123qwe")

returns NaN

In other words parseInt() parses up to the first non-digit and returns whatever it had parsed. Number() wants to convert the entire string into a number, which can also be a float BTW.


EDIT #1: Lucero commented about the radix that can be used along with parseInt(). As far as that is concerned, please see THE DOCTOR's answer below (I'm not going to copy that here, the doc shall have a fair share of the fame...).


EDIT #2: Regarding use cases: That's somewhat written between the lines already. Use Number() in cases where you indirectly want to check if the given string completely represents a numeric value, float or integer. parseInt()/parseFloat() aren't that strict as they just parse along and stop when the numeric value stops (radix!), which makes it useful when you need a numeric value at the front "in case there is one" (note that parseInt("hui") also returns NaN). And the biggest difference is the use of radix that Number() doesn't know of and parseInt() may indirectly guess from the given string (that can cause weird results sometimes).

Answer from sjngm on Stack Overflow
Top answer
1 of 6
421
parseInt("123qwe")

returns 123

Number("123qwe")

returns NaN

In other words parseInt() parses up to the first non-digit and returns whatever it had parsed. Number() wants to convert the entire string into a number, which can also be a float BTW.


EDIT #1: Lucero commented about the radix that can be used along with parseInt(). As far as that is concerned, please see THE DOCTOR's answer below (I'm not going to copy that here, the doc shall have a fair share of the fame...).


EDIT #2: Regarding use cases: That's somewhat written between the lines already. Use Number() in cases where you indirectly want to check if the given string completely represents a numeric value, float or integer. parseInt()/parseFloat() aren't that strict as they just parse along and stop when the numeric value stops (radix!), which makes it useful when you need a numeric value at the front "in case there is one" (note that parseInt("hui") also returns NaN). And the biggest difference is the use of radix that Number() doesn't know of and parseInt() may indirectly guess from the given string (that can cause weird results sometimes).

2 of 6
89

The first one takes two parameters:

parseInt(string, radix)

The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.

If the radix parameter is omitted, JavaScript assumes the following:

  • If the string begins with "0x", the
    radix is 16 (hexadecimal)
  • If the string begins with "0", the radix is 8 (octal). This feature
    is deprecated
  • If the string begins with any other value, the radix is 10 (decimal)

The other function you mentioned takes only one parameter:

Number(object)

The Number() function converts the object argument to a number that represents the object's value.

If the value cannot be converted to a legal number, NaN is returned.

🌐
Medium
medium.com › @emreavcilar › javascript-parseint-vs-number-8186ef8e29c1
JavaScript: parseInt() vs Number() | by Emre Avcılar | Medium
September 11, 2023 - In that case, Number() returns NaN. console.log(parseInt('5px')) // output 5 console.log(Number('5px')) // output NaN
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › what-is-the-difference-between-parseint-and-number
What is the difference between parseInt() and Number() ? - GeeksforGeeks
July 12, 2025 - If the argument could not be converted into a number, it returns a NaN value. This NaN value is not a valid number and cannot be used in any mathematical calculation. ... Example 1: This example shows that parseInt() tries to convert the value ...
🌐
Reddit
reddit.com › r/learnjavascript › number.parseint() vs. parseint()
r/learnjavascript on Reddit: Number.parseInt() vs. parseInt()
March 3, 2017 -

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/parseInt https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

What differs between Number.parseInt() and parseInt()?

🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Number(x) vs parseInt(x); - JavaScript - The freeCodeCamp Forum
April 30, 2018 - Whats the difference between these two things? i usually use parseInt() since its the one i learned first… but is there difference the two, or there is one that is more efficient or somethng?
🌐
Fantom's Blog
fantom0.hashnode.dev › parseint-vs-number-understanding-the-key-differences-in-javascript
parseInt vs Number: Key Differences in JavaScript
March 29, 2025 - While both parseInt() and Number() ... impact your JavaScript logic. parseInt() is useful for extracting integers from strings, whereas Number() is stricter and works well for full conversions....
Find elsewhere
🌐
DEV Community
dev.to › yns666 › difference-between-parseint-and-number-in-converting-strings-1fh5
Difference Between Number() and parseInt() in Converting Strings? - DEV Community
June 23, 2024 - If it finds anything else, it will return NaN (short for Not a Number). parseInt() / parseFloat(): Returns the first number in the string, ignoring the rest. If there are no numbers at the beginning of the string, it will return NaN.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › parseInt
Number.parseInt() - JavaScript | MDN
The Number.parseInt() static method parses a string argument and returns an integer of the specified radix or base.
🌐
Thisthat
thisthat.dev › number-constructor-vs-parse-int
Number() vs parseInt() - this vs that
As you see, parseInt will parse up to the first non-digit character. On the other hand, Number will try to convert the entire string.
🌐
Sololearn
sololearn.com › en › Discuss › 1612472 › whats-the-difference-between-new-number-and-parseint-in-javascript
What's the difference between new Number() and parseInt() in JavaScript? | Sololearn: Learn to code for FREE!
Number() accepts only "digit strings". For example: "34", "-56", "3.14", "6.022e23", etc. are all valid for Number() While, parseInt() accepts those strings which may or may not have non-digit character(s) at the end of string.
🌐
DEV Community
dev.to › darkmavis1980 › you-should-stop-using-parseint-nbf
You should stop using `parseInt()` - DEV Community
October 15, 2021 - Ok, but you did sum up the issue yourself in the examples. ParseInt will order to an integer whereas Number will get the proper numeric representation. Which means the outcome ma not be an int, which is what ParseInt guarantees .
🌐
Phrogz
phrogz.net › js › string_to_number.html
Benchmarking JavaScript String-to-Number Conversion
I only use parseInt() when I know that there will be non-numeric content at the end to ignore, or when I need to parse a non-base-10 string. I will sometimes use num = num << 0 when I need to truncate a number faster than Math.floor(), but never to convert a string to a number.
🌐
Medium
arek-jaworski.medium.com › difference-between-number-and-parseint-in-javascript-77f3ae9b735b
Difference between Number and parseInt in JavaScript | by Arek Jaworski | Medium
January 1, 2020 - parseInt('10'); // returns 10 ... returns 9 as radix is 8 parseInt('11', 10); // returns 11 · Number is a wrapper object that converts input values and returns…...
🌐
Artful
journal.artful.dev › what-you-risk-when-using-number-to-parse-an-integer-from-a-string-in-typescript
What you risk when using Number() to parse an integer from a string in TypeScript
May 15, 2023 - Number works with any input, but parseInt takes only string inputs. Technically, this is JavaScript with no types, and parseInt coerces any input into a string— but, that is an implementation detail.
🌐
Reddit
reddit.com › r/learnjavascript › confused about parseint() vs. number()...same thing, different context?
r/learnjavascript on Reddit: Confused about parseInt() vs. Number()...same thing, different context?
May 24, 2015 -

So I am a little confused concerning the difference between Number() and parseInt().

from my understanding, they are both extracting the integer used in a prompt; for example:

 var secretNumber = Number(prompt("enter your guess!", 5); 

vs.

 var secretNumber = prompt("enter your guess:", " ");

 secretNumber = parseInt(secretNumber); 

the only difference I see being that when you use Number(), there are no quotations around the number you would enter, compared to parseINT() which combs through a string to find the integer.

so essentially, one is used to comb through a string to find an integer, while the other strictly takes the integer entered without having to comb?

thanks for the help in advance!