Skip to content

Latest commit

 

History

History
64 lines (53 loc) · 2.25 KB

File metadata and controls

64 lines (53 loc) · 2.25 KB
title ms.custom ms.date ms.prod ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
parseInt Function (JavaScript) | Microsoft Docs
01/18/2017
windows-client-threshold
devlang-javascript
language-reference
parseInt
JavaScript
TypeScript
DHTML
parseInt method
e86471af-2a0e-4359-83af-f1ac81e51421
24
mikejo5000
mikejo
ghogen

parseInt Function (JavaScript)

Converts a string to an integer.

Syntax

parseInt(numString, [radix])   

Parameters

numString
Required. A string to convert into a number.

radix
Optional. A value between 2 and 36 that specifies the base of the number in numString. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.

Remarks

The parseInt function returns an integer value equal to the number contained in numString. If no prefix of numString can be successfully parsed into an integer, NaN (not a number) is returned.

parseInt("abc");     // Returns NaN.  
parseInt("12abc");   // Returns 12.  

You can test for NaN using the isNaN function.

Requirements

[!INCLUDEjsv1]

Applies To: Global Object

Note

Starting in [!INCLUDEjsv9textspecific], the parseInt function does not treat a string that has a prefix of '0' as an octal. When you are not using the parseInt function, however, strings with a prefix of '0' can still be interpreted as octals. See Data Types for information about octal integers.

See Also

isNaN Function
parseFloat Function
String Object
valueOf Method (Object)