天天看点

【JS】:JS中的Math对象详解

JS中Math有许多对象,这次我们需要自己讲的就是Math对象

Math对象就是方便我们运算的一个对象;

实际使用如下:

【JS】:JS中的Math对象详解

使用方法如下:

var x = Math.abs(t); //t是一个变量,使用方法就是大致如此~

给上一个实例代码感受一下:

<html>
<body>

<script type="text/javascript">

document.write(Math.round() + "<br />")
document.write(Math.round() + "<br />")
document.write(Math.round() + "<br />")
document.write(Math.round(-) + "<br />")
document.write(Math.round(-))

</script>

</body>
</html>
           

继续阅读