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>
![](https://img2022.cnblogs.com/blog/1413093/202206/1413093-20220604201700299-190253770.png)