Monday, July 27, 2026
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
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6972 POSTS0 COMMENTS