UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ Number/ Number.parseInt()

The Number.parseInt() static method parses a string argument and returns an integer of the specified radix or base.

Syntax

Number.parseInt(string)
Number.parseInt(string, radix)

Parameters

Return value

An integer parsed from the given string.

If the radix is smaller than 2 or bigger than 36, or the first non-whitespace character cannot be converted to a number, NaN is returned.

Examples

Number.parseInt vs. parseInt

This method has the same functionality as the global parseInt() function:

Number.parseInt === parseInt; // true

Its purpose is modularization of globals. Please see parseInt() for more detail and examples.

Specifications

Browser compatibility

See also