In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to understand JavaScript math, in view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
JavaScript's Math object allows you to perform mathematical operations on numbers. In the last article, we have introduced the basic usage of Math functions. In this article, we will talk about trigonometric functions and some other functions.
I. Trigonometric function
1. Math.sin ()
Math.sin (x) returns the sine of angle x (in radians) between-1 and 1.
If you want to use angles instead of radians, you must convert them to radians.
Angle in radians = Angle in degrees x PI / 180.
Project JavaScript Math.sin ()
Math.sin (x) returns the sine of x:
Angular Radian = (degree Angle) * PI / 180.
Document.getElementById ("demo") [xss_clean] = "the sine of 90 degrees is:" + Math.sin (90 * Math.PI / 180)
2. Math.cos ()
Math.cos (x) returns the cosine of x (in radians) between-1 and 1.
If you want to use angles instead of radians, you must convert them to radians.
Angle in radians = Angle in degrees x PI / 180.
Project JavaScript Math.cos ()
Math.cos (x) returns the cosine of x in radians:
Angular Radian = (degree Angle) * PI / 180.
Document.getElementById ("demo") [xss_clean] = "the cosine of 0 degrees is:" + Math.cos (0 * Math.PI / 180)
3. Other functions
1. Math.min ()
Math.min () and Math.max () can be used to find the lowest or highest values in the parameter list.
Document.getElementById ("demo") [xss_clean] = Math.min (0150,30,20,-8,200); / / returns-200
2. Math.max ()
Document.getElementById ("demo") [xss_clean] = Math.max (0,150,30,20,-8,200)
II. Math attribute (constant)
JavaScript provides eight mathematical constants that can be accessed by Math objects: (source Baidu).
Math.E / / returns Euler's number Math.PI / / returns PI Math.SQRT2 / / returns the square root of 2 Math.SQRT1_2 / / returns the square root of 1/2 Math.LN2 / / returns the natural logarithm of 2 Math.LN10 / / returns the natural logarithm of 10 Math.LOG2E / / returns base 2 logarithm of E Math.LOG10E / / returns base 10 logarithm of E
Starting from the most basic functions, explain the common methods of Math functions, there are trigonometric functions, as well as some other common functions, have done a detailed explanation. Analyze with a large number of cases, explain in detail how to use these methods and functions of Math function, as well as the difficulties encountered in practical application. The answer to the question on how to understand JavaScript math is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.
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.