Math.sqrt(x) -- 返回数字的平方根
- sqrt是square root 的缩写,中文"平方根"的意思
- 引用网址:http://www.dreamdu.com/javascript/Math.sqrt/
sqrt函数语法
Math
.
sqrt
(
x
)
;
sqrt函数参数
- x -- 为number类型的数字,此数字必须大于等于0
sqrt函数返回值
返回x的平方根
如果x小于0,返回NaN
sqrt函数示例
document
.
write
(
Math
.
sqrt
(
16
)
)
;
document
.
write
(
Math
.
sqrt
(
-
16
)
)
;
document
.
write
(
Math
.
sqrt
(
0
)
)
;
结果:
4 NaN 0