JavaScript Math.LN10 屬性



在 JavaScript 中,我們共有 8 個數學常量,可以作為 Math 屬性訪問,而 "Math.LN10" 就是其中之一。

JavaScript 的 **Math.LN10** 屬性用於表示 10 的自然對數,約等於 2.3025。此屬性等效於 Math.log(10)。

語法

以下是 JavaScript Math.LN10 屬性的語法:

Math.LN10

返回值

此屬性返回 10 的自然對數。

示例 1

在以下示例中,我們使用 JavaScript Math.LN10 屬性獲取 10 的自然對數:

<html>
<body>
<script>
   const result = Math.LN10;
   document.write(result);
</script>
</body>
</html>

輸出

執行上述程式後,我們將得到一個約等於 2.3025 的值。

示例 2

Math.LN10 屬性等效於 Math.log(10):

<html>
<body>
<script>
   const result = Math.log(10);
   document.write(result);
</script>
</body>
</html>

輸出

如果我們執行上述程式,Math.log(10) 將返回與 Math.LN10 相同的結果。

廣告