In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people do not know what to do about how to take the absolute value of javascript numbers. therefore, this paper summarizes the causes and solutions of the problem. I hope you can solve this problem through this article.
Javascript numbers take absolute value methods: 1, the use of Math object abs () method, syntax "Math.abs (number)"; 2, the use of "-" operator, syntax "- number"; 3, the use of "*" operator and sqrt () method, syntax "Math.sqrt (a)".
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Javascript numbers take absolute values
Method 1: use Math.abs ()
Var aaa=-20;console.log (Math.abs (aaa))
Method 2: use the "-" operator
Var aaa=-20;console.log (- aaa)
Note: when using the "-" operator to take an absolute value, you must make sure that the number is negative.
Method 3: using the "*" operator and the sqrt () method
First use the "*" operator to find the square value, and then use the sqrt () method to take the square root
Var Abercrombie Math. Sqrt (a); console.log (a)
What is JavaScript? JavaScript is a literal scripting language whose interpreter is called JavaScript engine and is a part of the browser. JavaScript is a scripting language widely used on the client side. It was first used on HTML pages to add dynamic functions to HTML pages.
After reading the above, have you mastered the method of how to take the absolute value of javascript numbers? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.