Does ParseInt Convert the "Format" or Also Convert the Value?


I'm a bit confused...

I understand, for example, parseInt("72") --> 72.
Or that parseInt("89") --> 89
So would parseInt("Hello, Allison") --> return NaN? Or would/could it return numerical value?

I ask, because it seemed that w3Schools is saying that if we use an alphabetical character than the parseInt method would return "NaN" ---- "Note: If the first character cannot be converted to a number, parseInt() returns NaN. w3Schools"

But this thread seems to be demonstrating that parseInt() can parse an alphabetic character into an integer.


The purpose of the parseInt() function is to take a number of one base and represent it in decimal (base 10) as an integer. The number cannot be presented as a number in the normal scheme of things JS, so must take the form of a string. parseInt() facilitates this transition.

We can only parse out numbers, though, else NaN is the return. Lots of things are not numbers, such as, 'A', or [] or {}. We will always get NaN from parseInt() if we don't supply it an actual number, regardless the base. This is where the radix comes in. We tell the function what base the parameter represents.

var bin = parseInt("10101010",2);
console.log(bin); // 100

We parsed the integer 100 out of the string representation of the binary equivalent.