You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In section Always Specify the Second ‘radix’ Parameter When Using .parseInt(), it is said that
When parsing a string to an integer, it is considered good practice to specify the second 'radix' parameter - which determines to what base the string should be converted to. It is, by default, octal/binary - so you will run into some problems.
This is actually not true. ECMA-262 specifies that
The parseInt function produces an integer value dictated by interpretation of the contents of the string argument according to the specified radix. Leading white space in string is ignored. If radix is undefined or 0, it is assumed to be 10 except when the number begins with the character pairs 0x or 0X, in which case a radix of 16 is assumed. If radix is 16, number may also optionally begin with the character pairs 0x or 0X.
I do not, nevertheless, challenge the importance of always specifying the radix.
The text was updated successfully, but these errors were encountered:
When radix is 0 or undefined and the string's number begins with a 0 digit not followed by an x or X,
then the implementation may, at its discretion, interpret the number either as being octal or as being
decimal. Implementations are encouraged to interpret numbers in this case as being decimal.
So the advice remains valid: always specify radix.
In section Always Specify the Second ‘radix’ Parameter When Using .parseInt(), it is said that
This is actually not true. ECMA-262 specifies that
I do not, nevertheless, challenge the importance of always specifying the radix.
The text was updated successfully, but these errors were encountered: