js取整

1.向上取整
Math.ceil(2.4)
// 输出3

2.四舍五入
// 输出2
Math.round(2.499)

// 输出3

 Math.round(2.6)

3.向下取整

// 输出2
Math.floor(2.9)

参考链接:https://blog.csdn.net/gongxiaoyi9511/article/details/108771245

posted @ 2022-01-05 15:48  northli  阅读(109)  评论(0编辑  收藏  举报