parseInt(string)
Previous  Top  Next

Syntax
parseInt(expression)

Arguments
expression: A string to convert to a integer.

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

Flash MX Differences
In Flash MX this function supports different input radix (bases) via an optional parameter.
Flash supports the concept of NaN, SWiSH returns 0 in these instances.

See Also
parseFloat(), parseInt()