0

Consider the following expression

console.log( 'result: ' + parseInt("1", 0) )

It returns 1 in the console of chrome (basically returns the decimal value).

The MDN docs for parseInt says

Or NaN when the radix is smaller than 2 or bigger than 36 ...

It would be great if someone could give an explanation for this.

Thanks in advance.

0

1 Answer 1

2

MDN is summarizing the specification, and is not complete.

The actual specification says:

If radix is undefined or 0, it is assumed to be 10 except when the number begins with the code unit pairs 0x or 0X, in which case a radix of 16 is assumed.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I also found a similar answer here -> developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… Turns out, I had to read further down. LOL.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.