Saturday, October 18, 2025
HomeLanguagesJavascriptLodash _.parseInt() Method

Lodash _.parseInt() Method

The _.parseInt() method is used to parse a string argument and returns an integer of the specified radix.

Syntax:

_.parseInt( string, [radix = 10] )

Parameters: This method accepts two parameters as mentioned above and described below:

  • string: This parameter holds the string to convert.
  • radix: This parameter holds the radix to interpret value by (This value defaults to 10).

Return Value: This method returns the converted integer.

Below examples illustrate the Lodash _.parseInt() method in JavaScript:

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
  
// Use of _.parseInt() method 
console.log(_.parseInt("10.33")); 
console.log(_.parseInt("8", 8));
console.log(_.parseInt("100", 10));


Output:

10
NaN
100

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
      
// Use of _.parseInt() method 
console.log(_.parseInt("0x10")); 
console.log(_.parseInt("10 year of gfg"));


Output:

16
10
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS