Friday, November 21, 2025
HomeLanguagesJavascriptLodash _.round() Method

Lodash _.round() 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 _.round() method is used to compute number rounded to precision.

Syntax:

_.round(number, [precision = 0])

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

  • number: This parameter holds the number to round.
  • [precision = 0]: This parameter holds the precision to round to.

Return Value: This method returns the rounded number.

Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library into the file.

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.round()  
// method 
let gfg = _.round(7.56); 
        
// Printing the output  
console.log(gfg);


Output:

8

Example 2:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.round()  
// method 
let gfg = _.round(9.005, 2); 
        
// Printing the output  
console.log(gfg);


Output:

9.01

Example 3:  

Javascript




// Requiring the lodash library  
const _ = require("lodash");  
    
// Use of _.round()  
// method 
let gfg = _.round(1980, -2); 
        
// Printing the output  
console.log(gfg);


Output:

2000
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11997 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS