[摘要]js中Math对象是什么?如何使用?本篇文章给大家带来的内容是介绍Math对象的属性和方法,让大家了解Math对象的使用方法。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。【相关视...
js中Math对象是什么?如何使用?本篇文章给大家带来的内容是介绍Math对象的属性和方法,让大家了解Math对象的使用方法。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。【相关视频教程推荐:JavaScript教程】
1. Math 对象的属性
(1) E :返回算术常量 e,即自然对数的底数(约等于2.718)。
(2) LN2 :返回 2 的自然对数(约等于0.693)。
(3) LN10 :返回 10 的自然对数(约等于2.302)。
(4) LOG2E :返回以 2 为底的 e 的对数(约等于 1.443)。
(5) LOG10E :返回以 10 为底的 e 的对数(约等于0.434)。
(6) PI :返回圆周率(约等于3.14159)。
(7) SQRT1_2 :返回返回 2 的平方根的倒数(约等于 0.707)。
(8) SQRT2 :返回 2 的平方根(约等于 1.414)。
<script type="text/javascript">
document.write('属性E<br/>');
document.write(Math.E);
document.write('<br/><br/>属性LN2<br/>');
document.write(Math.LN2);
document.write('<br/><br/>属性LN10<br/>');
document.write(Math.LN10);
document.write('<br/><br/>属性LOG2E<br/>');
document.write(Math.LOG2E);
document.write('<br/><br/>属性LOG10E<br/>');
document.write(Math.LOG10E);
document.write('<br/><br/>属性PI<br/>');
document.write(Math.PI);
document.write('<br/><br/>属性SQRT1_2<br/>');
document.write(Math.SQRT1_2);
document.write('<br/><br/>属性SQRT2<br/>');
document.write(Math.SQRT2);
</script>