Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Lodash _.parseInt() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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
My Personal Notes arrow_drop_up
Last Updated : 09 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials