From http://www.w3schools.com (Copyright Refsnes Data)
Complete Function Reference
The parseInt() function parses a string and returns an integer.
The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.
If the radix parameter is omitted, JavaScript assumes the following:
| parseInt(string, radix) |
| Parameter | Description |
|---|---|
| string | Required. The string to be parsed |
| radix | Optional. A number (from 2 to 36) that represents the numeral system to be used |
Note: Only the first number in the string is returned!
Note: Leading and trailing spaces are allowed.
Note: If the first character cannot be converted to a number, parseInt() returns NaN.
ExampleIn this example we will use parseInt() to parse different strings:
The output of the code above will be:
Try it yourself » |
Complete Function Reference
From http://www.w3schools.com (Copyright Refsnes Data)