Lodash教程

Lodash round method

语法

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

参数

number (number) − The number to round. [precision=0] (number) − The precision to round to.

输出

(number) − Returns the rounded number.

实例

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

输出

5
5.01
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4