It always a good practice to pass radix with parseInt -(用parseInt传递基数始终是一个好习惯-)
parseInt(string, radix)
For decimal -(对于小数-)
parseInt(id.substring(id.length - 1), 10)
If the radix parameter is omitted, JavaScript assumes the following:(如果省略了radix参数,则JavaScript假定以下内容:)
- If the string begins with "0x", the radix is 16 (hexadecimal)(如果字符串以“ 0x”开头,则基数为16(十六进制))
- If the string begins with "0", the radix is 8 (octal).(如果字符串以“ 0”开头,则基数为8(八进制)。) This feature is deprecated(不推荐使用此功能)
- If the string begins with any other value, the radix is 10 (decimal)(如果字符串以任何其他值开头,则基数为10(十进制))
( Reference )(( 参考 ))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…