Thursday, November 20, 2025
HomeLanguagesJavascriptLodash _.toNumber() Method

Lodash _.toNumber() Method

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc.

The _.toNumber() method is used to convert the given value to a number.

Syntax:

_.toNumber( value )

Parameters: This method accepts a single parameter as mentioned above and described below:

  • value: This parameter holds the value to convert.

Return Value: This method returns the converted number.

Example 1:

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
      
// Use of _.toNumber() method 
console.log(_.toNumber(15.6)); 
console.log(_.toNumber('15.6'));


Output:

15.6
15.6

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
      
// Use of _.toNumber() method 
console.log(_.toNumber(Number.MIN_VALUE)); 
console.log(_.toNumber(Number.MAX_VALUE));


 
Output:

5e-324
1.7976931348623157e+308
RELATED ARTICLES

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6776 POSTS0 COMMENTS
Nicole Veronica
11924 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6904 POSTS0 COMMENTS
Ted Musemwa
7160 POSTS0 COMMENTS
Thapelo Manthata
6859 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS