Math.sqrt

Returns the square root of a number.

Method of Math
Static

Syntax

sqrt( x )

Parameters

Parameter Description
x A number

Description

If the value of number is negative, sqrt returns NaN.
Because sqrt is a static method of Math, you always use it as Math.sqrt(), rather than as a method of a Math object you created.

Examples

The following function returns the square root of the variable x:

If you pass getRoot the value 9, it returns 3; if you pass it the value 2, it returns 1.414213562373095.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.