How to find the square root in JavaScript

WBOY
Release: 2022-04-11 12:09:06
Original
3239 people have browsed it

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)".

How to find the square root in JavaScript

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

How to find the square root in JavaScript

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)
Copy after login

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:

    123 

单击按钮显示不同数值的平方根。

Copy after login

Output result:

How to find the square root in JavaScript

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!