Math对象的log2()函数接受一个数字,并返回给定数字的自然对数(以2为底)。
其语法如下
Math.log2(48);
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = Math.log2(48);
document.write("Result: "+result);
</script>
</body>
</html>输出结果
Result: 5.584962500721156