freeCodeCamp/guide/chinese/javascript/standard-objects/math/math-sqrt/index.md

584 B

title localeTitle
Math Sqrt 数学Sqrt

数学Sqrt

函数Math.sqrt()返回数字的平方根。

如果输入负数,则返回NaN

sqrt()Math的静态方法,因此它总是被称为Math.sqrt()而不是另一个对象的方法。

句法

Math.sqrt(x) ,其中x是数字。

例子

Math.sqrt(25); // 5 
 Math.sqrt(169); // 13 
 Math.sqrt(3); // 1.732050807568 
 Math.sqrt(1); // 1 
 Math.sqrt(-5); // NaN 

更多信息:

MDN