parseInt from string to number in javascript

0

Syntax

parseInt(string, base);

Why does that numeral return?

parseInt("FXX123", 16);    
// retorna : 15

I understand that when the base is 16, it is used from A to F, because in the example it uses X and what is its value? And in what way is the conversion performed to result in 15?

Thanks

    
asked by user889 22.03.2018 в 00:41
source

1 answer

3

That's because a base 16 or hex is being specified. It returns to 15 because when it sees the F it analyzes it and then it meets X, which is NaN, due to this the rest of the chain is ignored.

Annex reference:

link

I hope I help you.

    
answered by 22.03.2018 в 00:53