Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Does javascript have a root function?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report