Standard built-ins
parseInt()
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
parseInt(value, radix?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | any | Converted to text before parsing. |
| radix | number | Base 2 through 36; omitted or zero uses prefix-based default. |
Return Value
number
Parsed Number, possibly NaN.
Working Example
Example Snippetjavascript
console.log(parseInt("12px",10));