ES6 - Math 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