JavaScript Math.sqrt()
Examples
let x = Math.sqrt(9);
Try it Yourself »
let a = Math.sqrt(0);
let b = Math.sqrt(1);
let c = Math.sqrt(9);
let d = Math.sqrt(64);
let e = Math.sqrt(-9);
Try it Yourself »
Definition and Usage
The Math.sqrt()
method returns the square root of a number.
Syntax
Math.sqrt(x)
Parameters
Parameter | Description |
x | Required. A number. |
Return Value
Type | Description |
Number | The square root of the number.NaN if the number negative. |
Browser Support
Math.
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |