What is JSlint error "missing radix parameter" in JavaScript?


The parseInt function available in JavaScript has the following signature −

parseInt(string, radix);

Where the parameters are the following −

string − The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.

radix − An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.

If the radix parameter is omitted, JavaScript assumes the following −

  • If the string begins with "0x", the radix is 16 (hexadecimal)

  • If the string begins with "0", the radix is 8 (octal). This feature is deprecated

  • If the string begins with any other value, the radix is 10 (decimal)

In order to avoid the above magic, JShint gives an error.

Updated on: 27-Nov-2019

611 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements