The second parameter of parseInt()
defines the base to which the first parameter is parsed to. I have been playing around with some numbers and found out that I do not get a correct answer anymore if the base is larger than 36:
parseInt("1", 36);
// -> 1
parseInt("1", 37);
// -> NaN
Is there a limit? And why is it 36?
I was using chrome when I ran my tests
The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems).
The parseInt method parses a value as a string and returns the first integer. A radix parameter specifies the number system to use: 2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal. If radix is omitted, JavaScript assumes radix 10.
By default radix is 10 (decimal).
parseInt takes two parameters, the second one is optional. String and Radix. String is the value to parse. If the value provided is not a string it will convert it to a string.
36 is 10 + 26. There are 26 letters in the alphabet, plus 0-9. That's the maximum radix you can use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With