parseInt() - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

converts its first argument to a string

The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN.

converted to a number

The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN.

thatNumber.toString(radix)

The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN.

outside the safe range

The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN.

numeric separators

parseInt() does not handle BigInt values. It stops at the n character, and treats the preceding string as a normal integer, with possible loss of precision.

Using parseInt() on non-strings

parseInt() can have interesting results when working on non-strings combined with a high radix; for example, 36 (which makes all alphanumeric characters valid numeric digits).

Number() constructor

Number.parseFloat()

Object.prototype.valueOf()

BigInt() constructor

Learn how to contribute

This page was last modified on Jul 8, 2025 by MDN contributors.

Expressions and operators

Numbers and strings

Representing dates & times

Regular expressions

Indexed collections