Home>Article>Web Front-end> Does javascript have a root function?

Does javascript have a root function?

青灯夜游
青灯夜游 Original
2022-03-28 18:52:16 5112browse

Javascript has a root function. In JavaScript, you can use the sqrt() function to find the square root, the syntax is "Math.sqrt(x)"; you can also use the pow() function to find the root of a specified power, the syntax is "pow(x,1/y) ”, which means opening the y-th root of x.

Does javascript have a root function?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

Javascript has a root function.

In javascript, you can use the following function to open the root:

  • sqrt() function

  • pow() function

1. Use the sqrt() function to open the root number

The sqrt() method can return the square root of a number.

This function does not support negative numbers. If the parameter is less than 0, it returns NaN.

Example:

Does javascript have a root function?

1. Use the pow() function to open the root

pow(x,y)can returnxraised to theypower.

When the parameteryis a fraction (greater than 0, less than 1), that is, pow(x,1/y) can open the y-th root of x.

Example:

Does javascript have a root function?

[Related recommendations:javascript video tutorial,web front-end]

The above is the detailed content of Does javascript have a root function?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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