其他分享
首页 > 其他分享> > JS Math对象

JS Math对象

作者:互联网

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
console.log(Math.abs(-100)) // 100 #绝对值
console.log(Math.ceil(3.14)) //4 #向上取整
console.log(Math.floor(3.94)) //3 #向下取整
console.log(Math.round(3.94)) //4 #四舍五入
console.log(Math.round(3.14)) //3 #四舍五入

// 0-100随机浮点数
console.log(Math.round(Math.random()*100))



</script>
</head>
<body>
<h1>welcome to JS!</h1>
</body>
</html>

 

标签:四舍五入,console,log,对象,JS,100,round,Math
来源: https://www.cnblogs.com/A121/p/16342652.html