649 B
649 B
title |
---|
Math Sqrt |
Math Sqrt
The function Math.sqrt()
returns the square root of a number.
If a negative number is entered, NaN
is returned.
sqrt()
is a static method of Math
, therefore it is always called as Math.sqrt()
rather than as a method on another object.
Syntax
Math.sqrt(x)
, where x
is a number.
Examples
Math.sqrt(25); // 5
Math.sqrt(169); // 13
Math.sqrt(3); // 1.732050807568
Math.sqrt(1); // 1
Math.sqrt(-5); // NaN