javascript Math对象 常用数字操作方法

 1  2  
 3  4 
 5 var t='1.2';
 6 parseInt(t) //1
 7 parseFloat(t)//1.2
 8 Number(1.2)//1.2强制转换为数字
 9 
10 
11 2.向上取整,有小数就整数部分加1 
12 js: Math.ceil(7/2) 
13 
14 3,四舍五入. 
15 js: Math.round(7/2) 
16 
17 4,向下取整
18 js: Math.floor(7/2)
19 
20 Math.abs() 绝对值
21 
22 
23 Math.floor(Math.random()*(100-10+1)+10);//100-10随机数
原文地址:https://www.cnblogs.com/weihexinCode/p/12318307.html