int

Commons
stable

Thin wrapper around parseInt with a default radix of 10. Accepts both string and number inputs.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

value
requis
string | number
The value to parse. Strings are parsed as integers; numbers are passed to parseInt directly.
radix
number
10
The base for the parseInt call. Defaults to 10 (decimal). Use 16 for hex strings.

API

Valeur de retour

La valeur retournée par cet util.

The parsed integer. Returns NaN for non-numeric input (same as parseInt behaviour).

Usage

Exemples

Extraits de code prêts à coller.

Parse integers from strings

typescript