sqrt()
Math
class method
JS Home <<
JS Reference <<
Math <<
sqrt()
Description
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.
Syntax
Signature | Description |
---|---|
Math.sqrt(value) | Returns the positive square root of a number. |
Parameters
Parameter | Description |
---|---|
value | The value you wish to find the sqrt() of:
|
Examples
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);
alert(sqrtValues);
Related Tutorials
JavaScript Advanced Tutorials - Lesson 4 - Math