JSLint says “missing radix parameter”

前端 未结 11 1283
北荒
北荒 2020-11-30 17:10

I ran JSLint on this JavaScript code and it said:

Problem at line 32 character 30: Missing radix parameter.

This is the code i

11条回答
  •  孤城傲影
    2020-11-30 17:45

    I'm not properly answering the question but, I think it makes sense to clear why we should specify the radix.

    On MDN documentation we can read that:

    If radix is undefined or 0 (or absent), JavaScript assumes the following:

    • [...]
    • 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.
    • [...]

    Source: MDN parseInt()

提交回复
热议问题