JS取整数、取余数的方法

1.丢弃小数部分,保留整数部分dom parseInt(5/2)spa 2.向上取整,有小数就整数部分加1对象  Math.ceil(5/2)随机数 3,四舍五入.方法 Math.round(5/2)co 4,取余源代码 6%4ab 5,向下取整  Math.floor(5/2) Math 对象的方法 FF: Firefox, N: Netscape, IE: Internet Explorer
相关文章
相关标签/搜索