Math sqrt() method
JavaScript Math sqrt() method
Last Updated : 17 Mar 2025
The JavaScript math sqrt() method returns the square root of a number. If the provided number is negative, it returns NaN.
Syntax
The sqrt() method is represented by the following syntax:
Parameter
num - A number.
Return
The square root of the given number.
JavaScript Math sqrt() method example
Here, we will understand sqrt() method through various examples.
Example 1
Let's see an example to print square root of the given numbers.
Output:
Example 2
Let's see some cases where sqrt() method returns NaN.
Output:
Example 3
Here, you can test sqrt() method with your own test cases.