I have the following code that gives the warning described in the title:
year: parseInt(dateParts[0]),
......................^
Any help is much appreciated
I have the following code that gives the warning described in the title:
year: parseInt(dateParts[0]),
......................^
Any help is much appreciated
See the manual for parseInt
; it takes 2 arguments. The second one tells it which number base you want to use. This is almost always going to be 10
(decimal).
parseInt(dateParts[0],10)
If you don't specify it, then it will be inferred from the data.
If radix is undefined or 0 (or absent), JavaScript assumes the following:
If the input string begins with "0x" or "0X", radix is 16 (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 using parseInt.
If the input string begins with any other value, the radix is 10 (decimal).