parseInt(string)
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
parseInt(expression, {radix})

Arguments
expression: A string to convert to a integer.
radix: An optional argument used to represent the radix (base) of the integer. Acceptable values range from 2-36.

Returns
An integer.

Description
Function: Converts a string to an integer. If the specified string in the Arguments cannot be converted to a number, the function returns 0. All strings are assumed to be base 10.
If the string represents a floating-point number, that number is truncated.

Sample
The following examples use the parseInt function to evaluate various types of numbers:

parseInt("3
.5") 
// returns 3


parseInt("-3
.5") 
// returns -3


parseInt("bar")
// returns 0


parseInt("4foo")
// returns 4

parseInt("3.5", 5);
// returns 3


See Also
parseFloat()