O'Reilly logo

Learning WML, and WMLScript by Martin Frost

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

parseInt — Convert a string to an integer

Usage

Lang.parseInt(str)

str : String

Description

Attempts to parse the string str as a decimal integer. A leading + or - may be included; any spaces at the start of the string are ignored, as are any characters at the end that can’t be parsed as part of the integer.

If str can’t be parsed as an integer, returns invalid.

Examples

Lang.parseInt("17")

returns integer 17

Lang.parseInt("23.67")

returns integer 23

Lang.parseInt(" -63 percent")

returns integer -63

Lang.parseInt("+4inches")

returns integer 4

Lang.parseInt(true)

returns invalid

Lang.parseInt(".3")

returns invalid

Lang.parseInt("+")

returns invalid

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required