
- CoffeeScript 教程
- CoffeeScript - 主頁
- CoffeeScript - 概述
- CoffeeScript - 環境
- CoffeeScript - 命令列實用程式
- CoffeeScript - 語法
- CoffeeScript - 資料型別
- CoffeeScript - 變數
- CoffeeScript - 運算子和別名
- CoffeeScript - 條件語句
- CoffeeScript - 迴圈
- CoffeeScript - 雜湊
- CoffeeScript - 函式
- 面向物件中的 CoffeeScript
- CoffeeScript - 字串
- CoffeeScript - 陣列
- CoffeeScript - 物件
- CoffeeScript - 範圍
- CoffeeScript - 擴充套件運算子
- CoffeeScript - 日期
- CoffeeScript - 數學
- CoffeeScript - 異常處理
- CoffeeScript - 正則表示式
- CoffeeScript - 類和繼承
- 高階 CoffeeScript
- CoffeeScript - Ajax
- CoffeeScript - jQuery
- CoffeeScript - MongoDB
- CoffeeScript - SQLite
- CoffeeScript 有用資源
- CoffeeScript - 快速指南
- CoffeeScript - 有用資源
- CoffeeScript - 討論
CoffeeScript 數學 - exp()
描述
exp() 方法接受一個數字並返回其 Ex 值。其中 x 為引數,E 為自然對數的底數尤拉常數
語法
以下是 JavaScript 中 exp() 方法的語法。我們可以在 CoffeeScript 程式碼中使用相同的方法。
Math.exp ( x )
示例
以下示例演示了 CoffeeScript 中 exp() 方法的用法。將此程式碼儲存在名為 math_exp.coffee 的檔案中。
value = Math.exp 1 console.log "The exponential value of 1 is : " + value value = Math.exp 52 console.log "The exponential value of 52 is : " + value value = Math.exp 0.78 console.log "The absolute value of 0.78 is : " + value
開啟 命令提示符 並按如下所示編譯 .coffee 檔案。
c:\> coffee -c math_exp.coffee
編譯時,會生成以下 JavaScript。
// Generated by CoffeeScript 1.10.0 (function() { var value; value = Math.exp(1); console.log("The exponential value of 1 is : " + value); value = Math.exp(52); console.log("The exponential value of 52 is : " + value); value = Math.exp(0.78); console.log("The absolute value of 0.78 is : " + value); }).call(this);
現在,再次開啟 命令提示符 並按如下所示執行 CoffeeScript 檔案。
c:\> coffee math_exp.coffee
CoffeeScript 檔案執行時,將生成以下輸出。
The exponential value of 1 is : 2.718281828459045 The exponential value of 52 is : 3.831008000716576e+22 The absolute value of 0.78 is : 2.1814722654982015
coffeescript_math.htm
廣告