2020
12-04
12-04
JavaScript十大取整方法实例教程
1.parseInt()//js内置函数,注意接受参数是string,所以调用该方法时存在类型转换parseInt("1.5555")//=>12.Number.toFixed(0)//注意toFixed返回的字符串,若想获得整数还需要做类型转换1.5555.toFixed(0)//=>"1"3.Math.ceil()//向上取整Math.ceil(1.5555)//=>24.Math.floor()//向下取整Math.floor(1.5555)//=>15.Math.round()//四舍五入取整Math.round(1.5555)//=>2Math.round(1.4999)//=>16.Math.t...
继续阅读 >