Others



JavaScript Math.sqrt()


The Math.sqrt(x) method used to returns the square root of a number.

Syntax
Math.sqrt(x)

Here, sqrt() is a static method. Hence, we use it as Math.sqrt().

Parameters
  • x - (Required).A number.
Return Value
  • Number - The square root of the number.
  • NaN - if the number is less than 0.
Example
console.log(Math.sqrt(25));  //5
console.log(Math.sqrt(9));  //3
console.log(Math.sqrt(0));  //0
console.log(Math.sqrt(-25)); //NaN
Try it Yourself

JavaScript Math Functions