JavaScript sqrt() method
- Previous Page sinh()
- Next Page SQRT1_2
- Go Back to the Previous Level JavaScript Math Reference Manual
Definition and usage
sqrt()
The method returns the square root of a number.
Instance
Example 1
Return the square root of a number:
Math.sqrt(9);
Example 2
Return the square root of different numbers:
var a = Math.sqrt(0); var b = Math.sqrt(1); var c = Math.sqrt(9); var d = Math.sqrt(64); var e = Math.sqrt(-9);
Syntax
Math.sqrt(x)
Parameter value
Parameter | Description |
---|---|
x | Required. Number. |
Technical details
Return value: | Value. If x is negative, it returns NaN. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
sqrt() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Mathematics
- Previous Page sinh()
- Next Page SQRT1_2
- Go Back to the Previous Level JavaScript Math Reference Manual