Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

parseInt

The parseInt() function of the Global object is used to return an integer(whole number) from a string argument and an optional radix.

SyntaxparseInt( string, radix )

Parameters

string The string to parsed as an integer. radix An optional value between 2 and 36 that specifies the base of the number in the string parameter. Strings with a prefix of '0x' are hexadecimal. If radix is undefined or 0, it is assumed to be 10 except when the number begins with hexadecimal '0x' or '0X', then a radix of 16 is assumed.

Examples

var a = parseInt( "5", 0 ); var b = parseInt( "9.8", 0 ); var c = parseInt( "45deg", 0 ); var d = parseInt( "kitty cat", 0 ); alert( typeof a + " - " + a ); /* number - 5 */ alert( typeof b + " - " + b ); /* number - 9 */ alert( typeof c + " - " + c ); /* number - 45 */ alert( typeof d + " - " + d ); /* number - NaN */

JavaScript

Methods

addEventListeneralertaveragebackblurconcatcreatedecodeURIdecodeURIComponentencodeURIencodeURIComponentevaleveryfilterforwardgoisArrayisFiniteisNaNjoinparseFloatparseIntpoppushpushStatereducereplaceStatereverseshiftshuffleslicesomesortspliceunshiftwrite