Last Updated : 03 Nov, 2023
Lodash _.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 returns the converted integer.
Example 1: In this example, we are getting the converted integer of the given value.
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: In this example, we are getting the converted integer of the given value.
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4