Es6-math-function-sqrt

提供:Dev Guides
2020年6月23日 (火) 08:04時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

ES6-数学sqrt()関数

このメソッドは、数値の平方根を返します。 数値の値が負の場合、sqrtはNaNを返します。

構文

Math.sqrt ( x );

パラメータ

  • x-数値を表します

戻り値

数値の平方根を返します。

console.log("---Math.sqrt()---")
console.log("Math.sqrt(16) : "+Math.sqrt(16)
console.log("Math.sqrt(15.5) : "+Math.sqrt(15.5))

出力

---Math.sqrt()---
Math.sqrt(16) : 4
Math.sqrt(15.5) : 3.9370039370059056