JavaScript Number parseInt() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report TheparseInt method parses a value as a string and returns the first integer. It accepts a string argument and optional radix parameter, defining the numeral system base. This method is commonly used for converting string representations of numbers into integers. Example: The method takes two parameters: the string to be parsed and the radix (optional, default is 10).2 = binary, 8 = octal, 10 = decimal, 16 = hexadecimal.Syntax parseInt(Value, radix);Parameters Value: This parameter contains a string that is converted to an integer.radix: This parameter represents the radix or base to be used and it is optional.Return value It returns a number and if the first character can't be converted to a number then the function returns NaN. It returns a number parsed up to that point where it encounters a character that is not a number in the specified radix(base). Example 1: Parsing float value Here, we are using the parseInt() method to parse the given float value. javascript let v1 = parseInt("3.14"); console.log('Using parseInt("3.14") = '+ v1); OutputUsing parseInt("3.14") = 3 Example 2: Parsing value with given radix Here, we will also mention radix with the number. javascript // Base 10 a = parseInt("100", 10); console.log('parseInt("100",10) = ' + a); // Base 8 b = parseInt("8", 8); console.log('parseInt("8",8) = ' + b); // Base 8 c = parseInt("15", 8); console.log('parseInt("15",8) = ' + c); // Base 16 d = parseInt("16", 16); console.log('parseInt("16",16) = ' + d); // Leading and trailing spaces are ignored // in parseInt() function e = parseInt(" 100 "); console.log('parseInt(" 100 ") = ' + e); // Base 16(hexadecimal) f = parseInt("0x16"); console.log('parseInt("0x16") = ' + f); OutputparseInt("100",10) = 100 parseInt("8",8) = NaN parseInt("15",8) = 13 parseInt("16",16) = 22 parseInt(" 100 ") = 100 parseInt("0x16") = 22 We have a complete list of JavaScript Number constructor, properties, and methods list, to know more about the numbers please go through that article. Supported BrowsersGoogle ChromeEdge Internet Explorer Firefox OperaSafari Comment More infoAdvertise with us V vivekkothari Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Numbers JavaScript-Methods Explore JavaScript BasicsIntroduction to JavaScript4 min readJavaScript Versions2 min readHow to Add JavaScript in HTML Document?3 min readJavaScript Syntax6 min readJavaScript Output4 min readJavaScript Comments2 min readVariables & DatatypesVariables and Datatypes in JavaScript6 min readGlobal and Local variables in JavaScript4 min readJavaScript Let6 min readJavaScript const5 min readJavaScript Var Statement7 min readOperatorsJavaScript Operators5 min readOperator precedence in JavaScript2 min readJavaScript Arithmetic Operators5 min readJavaScript Assignment Operators5 min readJavaScript Comparison Operators5 min readJavaScript Logical Operators5 min readJavaScript Bitwise Operators5 min readJavaScript Ternary Operator4 min readJavaScript Comma Operator2 min readJavaScript Unary Operators4 min readJavaScript in and instanceof operators3 min readJavaScript String Operators3 min readStatementsJavaScript Statements4 min readJavaScript if-else3 min readJavaScript switch Statement4 min readJavaScript Break Statement2 min readJavaScript Continue Statement1 min readJavaScript Return Statement4 min readLoopsJavaScript Loops3 min readJavaScript For Loop4 min readJavaScript While Loop3 min readJavaScript For In Loop3 min readJavaScript for...of Loop3 min readJavaScript do...while Loop4 min readPerformance & DebuggingJavaScript | Performance4 min readDebugging in JavaScript4 min readJavaScript Errors Throw and Try to Catch2 min readObjectsObjects in Javascript4 min readObject Oriented Programming in JavaScript3 min readJavaScript Objects6 min readCreating objects in JavaScript5 min readJavaScript JSON Objects3 min readJavaScript Object Reference4 min readFunctionsFunctions in JavaScript5 min readHow to write a function in JavaScript ?4 min readJavaScript Function Call2 min readDifferent ways of writing functions in JavaScript3 min readDifference between Methods and Functions in JavaScript3 min readExplain the Different Function States in JavaScript3 min readJavaScript Function Complete Reference3 min readArraysJavaScript Arrays7 min readJavaScript Array Methods7 min readBest-Known JavaScript Array Methods6 min readImportant Array Methods of JavaScript7 min readJavaScript Array Reference4 min readStringJavaScript Strings6 min readJavaScript String Methods9 min readJavaScript String Reference4 min read Like