- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - round method
Syntax
_.round(number, [precision=0])
Computes number rounded to precision.
Arguments
number (number) − The number to round.
[precision=0] (number) − The precision to round to.
Output
(number) − Returns the rounded number.
Example
var _ = require('lodash'); var result = _.round( 5.006); console.log(result); result = _.round( 5.006, 2); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
5 5.01
lodash_math.htm
Advertisements