next up previous contents
Next: escape Up: Methods Previous: parseFloat   Contents


parseInt

Description

Converts strings into integers.


Syntax

parseInt(string, [radix])


Parameters

string
Required. A string to convert into a number.
radix
Optional. A value between 2 and 36 indicating the base of the number contained in string. If not supplied, strings with a prefix of `0x' are considered hexidecimal and strings with a prefix of `0' are considered octal. All other strings are considered decimal.


Returns

The parseInt method returns an integer value equal to the number contained in string. If no prefix of string can be successfully parsed into an integer, NaN (not a number) is returned.


Examples

parseInt("abc")    // Returns NaN.
parseInt("12abc")  // Returns 12.
//You can test for NaN by using the isNaN method.




Copyright ©2000-2007 Shanghai TopCMM Software Technologies. All Rights Reserved.