round()方法

四舍五入为整数
 

    console.log(Math.round(0.60))   // 1    入
    console.log(Math.round(0.50))   // 1    入
    console.log(Math.round(0.49))   // 0    舍
    console.log(Math.round(-4.40))  // -4   舍
    console.log(Math.round(-4.60))  // -5   入

猜你喜欢

转载自blog.csdn.net/qq_33650655/article/details/92059987