下面是一个例子 数学LN2() 方法
null
- 例子:
javascript
<script> // Here value of Math.LN2 is printed. document.write(Math.LN2); </script> |
- 输出:
0.6931471805599453
这个 数学液氮 是JavaScript中的一个属性,仅用于查找自然日志2的值。自然对数的基数为e,表示为ln。2的自然对数表示为ln(2),其值约为0.693。 语法:
Math.LN2;
参数: 此方法不接受任何参数。 返回值: 它只返回自然对数2的值。 下面的示例演示了JavaScript中的Math LN2属性。
- 例子: 这里只是自然对数2的值,即数学。LN2显示为输出。
Input : Math.LN2Output : 0.6931471805599453
以上房产的更多代码如下: 项目1: 自然对数2的值可以按如下所示的函数形式打印。
javascript
<script> // function is being called. function get_Value_of_natural_log_of_2() { return Math.LN2; } // Calling Function. document.write(get_Value_of_natural_log_of_2()); </script> |
输出:
0.6931471805599453
项目2: 这里我们考虑数学。LN2是一个函数,但实际上它是一个属性,这就是为什么显示输出错误的原因。
javascript
<script> // Here we consider Math.LN2 as a // function but in actual it // is a property that is why error as // output is being shown. document.write(Math.LN2(12)); </script> |
输出:
Error: Math.LN2 is not a function
注: 检查控制台是否有错误。 支持的浏览器:
- 谷歌Chrome 1及以上版本
- Internet Explorer 3及以上版本
- 边缘12及以上
- Firefox 1及以上版本
- 歌剧3及以上
- Safari 1及以上
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END