JavaScript parseint () function
JavaScript Global Objects
Definition and usage
The parseint () function parses a string and returns an integer.
Grammar
parseint (stringradix)
Parameters |
Description |
String |
Necessary. The string to be parsed. |
Radix |
Optional. Represents the cardinality of the number to parse. The value is between 2 and 36. If this argument is omitted or its value is 0, the number is parsed based on 10. If it starts with "0x" or "0X", it will have a base of 16. If the parameter is less than 2 or greater than 36, parseint () returns NaN. |
return value
Returns the parsed number.
Description
When the value of the parameter radix is 0, or if the parameter is not set, parseint () determines the cardinality of the number based on string .
For example, if string starts with "0x", parseint () resolves the remainder of the string to a 16-binary integer. If string starts with 0, then ECMAScript V3 allows an implementation of parseint () to parse subsequent characters into octal or hexadecimal digits. If string starts with a number from 1 to 9, parseint () parses it into a decimal integer.
JavaScript parseint () function