Standard built-ins

Number.parseInt()

Try the free JavaScript compiler

The Number static property refers to the same built-in function as the corresponding global parser. Reads an integer prefix in a selected radix; ignores trailing invalid digits and yields NaN if no valid prefix exists.

Formal Syntax & Structure

javascript syntaxjavascript
Number.parseInt(value, radix?)

Parameters & Attributes

NameTypeDescription
valueanyConverted to text before parsing.
radixnumberBase 2 through 36; omitted or zero uses prefix-based default.

Return Value

number

Parsed Number, possibly NaN.

Working Example

Example Snippetjavascript
console.log(Number.parseInt("12px",10));
JavaScript Reference