Math.round(变量) (用于数字取整:四舍五入)
注:Math.round()以后类型是number
var str = "1.534";
var num = Math.round(str);
console.log(num); // number
console.log(typeof num); //控制台打印输出2
变量 . toFixed(保留位数) :可以指定四舍五入保留位数
注:toFixed以后类型是string
var num1 = 3.141592657;
num1 = num1.toFixed(4); // 把小数保留4位,四舍五入
console.log(num1);//打印3.1416
console.log(typeof num1); // string