sqrt()  Math  class methodS2C Home  « Globals « Math « sqrt()


Returns the positive square root of a number.

  • Like all class methods sqrt() should be used on the class rather than an instance of the class.


Signature Description
Math.sqrt(value)Returns the positive square root of a number.


Parameter Description
valueThe value you wish to find the sqrt() of:
  • Negative numbers returns NaN.
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.


The code below displays sqrt() usage.

 * Store results in an array.
var sqrtValues = new Array(6);
sqrtValues[0] = Math.sqrt(1.49);
sqrtValues[1] = Math.sqrt(-10.5);
sqrtValues[2] = Math.sqrt('100.5');
sqrtValues[3] = Math.sqrt('five');
sqrtValues[4] = Math.sqrt();
sqrtValues[5] = Math.sqrt(null);

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math

go to home page Homepage go to top of page Top