Coffeescript-math-asin
提供:Dev Guides
CoffeeScript Math-asin()
説明
- asin()*メソッドは整数値を受け入れ、そのアークサインをラジアンで返します。 asinメソッドは、-1〜1のxに対して-pi/2〜pi/2ラジアンの数値を返します。 numberの値がこの範囲外の場合、NaNを返します。
構文
以下に、JavaScriptの* asin()*メソッドの構文を示します。 CoffeeScriptコードで同じメソッドを使用できます。
Math.asin( x )
例
次の例は、CoffeeScriptでの* asin()メソッドの使用方法を示しています。 このコードを *math_asin.coffee という名前のファイルに保存します。
value = Math.asin -1
console.log "The arc sine value of -1 is : " + value
value = Math.asin null
console.log "The arc sine value of null is : " + value
value = Math.asin 20
console.log "The arc sine value of 20 is : " + value
- コマンドプロンプト*を開き、以下に示すように.coffeeファイルをコンパイルします。
c:\> coffee -c math_asin.coffee
コンパイル時に、次のJavaScriptが提供されます。
//Generated by CoffeeScript 1.10.0
(function() {
var value;
value = Math.asin(-1);
console.log("The arc sine value of -1 is : " + value);
value = Math.asin(null);
console.log("The arc sine value of null is : " + value);
value = Math.asin(20);
console.log("The arc sine value of 20 is : " + value);
}).call(this);
次に、*コマンドプロンプト*を再度開き、以下に示すようにCoffeeScriptファイルを実行します。
c:\> coffee math_asin.coffee
CoffeeScriptファイルを実行すると、次の出力が生成されます。
The arc sine value of -1 is : -1.5707963267948966
The arc sine value of null is : 0
The arc sine value of 20 is : NaN