javascript Global parseInt( )
parseInt( ) | Firefox/Netscape/NN 2 IE 3 ECMA 1 |
parseInt("string "[, radix]) | |
Returns an integer value (as a number data type in base-8 or base-10) of the numerals in the string passed as a parameter. The string value must at least begin with a numeral, or the result is NaN. If the string starts with numbers but changes to letters along the way or includes white space, only the leading numbers up to the first nonnumeral or whitespace are converted to the integer. Therefore, you can use the expression: parseInt(navigator.appVersion) |
|
to extract only the whole number of the version that leads the otherwise long string that is returned from that property. |
|
The optional radix parameter lets you specify the base of the number being passed to the function. A number string that begins with zero is normally treated as an octal number, which gives you the wrong answer. It is a good idea to use the radix value of 10 on all parseInt( ) functions if all of your dealings are in base-10 numbers. |
|
Parameters | |
|
|
Returned Value | |
Integer. |
Powered by Linode.