Get the App
SLTechnology News&Howtos  ›  Development  › 

Does javascript have a root function?

Shulou Source: shulou.com Published: 2022-06-01 03:01:34 10月04日 Update

This article introduces the relevant knowledge of "does javascript have a root function". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Javascript has a root function. In javascript, you can use the sqrt () function to find the square root, the syntax "Math.sqrt (x)", or you can use the pow () function to open the root sign of the specified power, and the syntax "pow (xmai 1compy)" represents the root of x to the y power.

The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.

Javascript has a root function.

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

Sqrt () function

Pow () function

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

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

This function does not support negative numbers and returns NaN if the parameter is less than 0.

Example:

Console.log (Math.sqrt (1)); console.log (Math.sqrt (4)); console.log (Math.sqrt (9)); console.log (Math.sqrt (64)); console.log (Math.sqrt (- 9))

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

Pow (xPowery) returns x to the power of y.

When the parameter y is a fraction (greater than 0, less than 1), that is to say, pow (x _ meme _ 1p _ y) can open the y-th root of x.

Example:

Console.log (Math.pow (4); console.log (Math.pow (81); console.log (256))

This is the end of the content of "does javascript have a root function". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Function root sign content parameter square root more knowledge example grammar utility learning and then number score can make dilemma reality situation tutorial article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Huawei Shulou Tech Info Shulou Information