javascript中round的意思是什么

javascript中round的意思是什么
round() 方法可把一个数字舍入为最接近的整数。
注意: 2.49 将舍入2 , 2.5 将舍入 3。
所有主要浏览器都支持 round() 方法
语法
Math.round(x)
x 必需。必须是数字。
示例如下:
<html>
<head>
<meta charset="utf-8">
<title>123</title>
</head>
<body>
<p id="demo">单击按钮舍入与“2.5”最接近的整数</p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction(){
document.getElementById("demo").innerHTML=Math.round(2.5);
}
</script>
</body>
</html>输出结果:

点击按钮后:

相关推荐:javascript学习教程
 
                    					 javascript
javascript