JavaScript sqrt () method
Definition and Usage
sqrt () method returns the square root of a number.
Browser Support
All major browsers support sqrt () method
grammar
Math.sqrt( x )
Parameter Value
参数 | 描述 |
---|---|
x | 必需。必须是大于等于 0 的数。 |
return value
类型 | 描述 |
---|---|
Number/NaN | 参数 x 的平方根。如果 x 小于 0,则返回 NaN。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
In this case, we will return to the square root of the different figures:
var a=Math.sqrt(0);
var b=Math.sqrt(1);
var c=Math.sqrt(9);
var d=Math.sqrt(64);
var e=Math.sqrt(-9);
var b=Math.sqrt(1);
var c=Math.sqrt(9);
var d=Math.sqrt(64);
var e=Math.sqrt(-9);
a, b, c, d, and e output:
0
1
3
8
NaN
1
3
8
NaN
try it"