无涯教程-Math.sqrt(x)函数

56 阅读1分钟

此方法返回数字的平方根。如果数字的值为负,则sqrt返回NaN。

语法

Math.sqrt ( x );  

参数

  • x-代表数字

返回值

返回数字的平方根。

Example

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             

参考链接

www.learnfk.com/es6/es6-mat…