3 ms·
> parseInt("0123Test") 123 > 0123 83 parseInt is actually the adult in the room
by yread 7y ago
> parseInt("0123Test")
123
> 0123
83
parseInt is actually the adult in the room
- TeMPOraL 7y agoIn a way. The convention is that 0123 is "123" in octal.
- yread 7y agoYes, I know that's why I even tried it in console as I was a bit surprised that parseInt doesn't do octal. Why does js even support octal? I never found octal particularly useful. Speak hexadecimal or die
- sweeneyrod 7y agoBecause C does.
- hurflmurfl 7y ago> parseInt('0123Test', 8) 83 you could do it like this, otherwise it uses the default value for the base parameter.