JavaScript Math.sqrt()
Definition and Usage
The Math.sqrt() method returns the square root of a number.
Example 2
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 »
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 |
Syntax
Math.sqrt(x)
Parameters
Parameter | Description |
---|---|
x | Required. A number |
Return Value
A number. If x is a negative number, NaN is returned. |