Reputation: 6131
I was not able to find definite answer, do we still need to use radix (Node)?
let number = parseInt('666');
VS
let number = parseInt('666', 10);
Upvotes: 0
Views: 257
Reputation: 386654
Form MDN to parseInt
:
If radix is
undefined
or0
(or absent), JavaScript assumes the following:
If the input
string
begins with"0x"
or"0X"
, radix is16
(hexadecimal) and the remainder of the string is parsed.If the input
string
begins with "0", radix is eight (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 specifies that 10 (decimal) is used, but not all browsers support this yet. For this reason always specify a radix when usingparseInt
.If the input
string
begins with any other value, the radix is 10 (decimal).
Upvotes: 2