JavaScript Math.sqrt() Method
The Math.sqrt() static method returns the square root of a number.
Description
The Math.sqrt() static method returns the square root of a number. Negative numbers return NaN. It's the same as x ** 0.5.
Math.sqrt(-0) returns -0, and numbers that aren't perfect squares produce floating point results such as 1.4142135623730951 for 2. Math.SQRT2 and Math.SQRT1_2 are built-in constants for the square roots of 2 and one-half.
Square roots are used for distances, areas, standard deviations and normalizing vectors. For the distance between two points, Math.hypot() combines the squaring, adding and square root in one call. Like every member of Math, it's called on the Math object itself rather than on a number, and it only works with the Number type: passing a BigInt throws a TypeError.
Syntax
Math.sqrt(x)Parameters
- xA number, 0 or greater.
Return Value
The square root of x, or NaN if it is negative.
Example
Browser Support
The following information will show you the current browser support for the Math.sqrt() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





