Home>Article>Web Front-end> Does javascript have a root function?
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.
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:
1. Use the pow() function to open the root
pow(x,y)
can returnx
raised to they
power.
When the parametery
is a fraction (greater than 0, less than 1), that is, pow(x,1/y) can open the y-th root of x.
Example:
[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!