In JavaScript, you can use the sqrt() method to achieve the effect of finding the square root. This method is used to return the square root of a number. The parameter value in the method must be a number, and when the parameter in the method is less than zero When , the returned result is "NaN", and the syntax is "Math.sqrt (the value requiring the square root)".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
You can use the sqrt() method to find the square root.
The sqrt() method returns the square root of a number.
The syntax is:
Math.sqrt(x)
Parameter x is required. Must be a number greater than or equal to 0.
The returned result is: the square root of parameter x. If x is less than 0, returns NaN.
The example is as follows:
Output result:
[Related recommendations:javascript video tutorial,webfrontend】
The above is the detailed content of How to find the square root in JavaScript. For more information, please follow other related articles on the PHP Chinese website!