Saturday, January 31, 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
32478 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6849 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12066 POSTS0 COMMENTS
Shaida Kate Naidoo
6987 POSTS0 COMMENTS
Ted Musemwa
7222 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6917 POSTS0 COMMENTS