In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use the Math method in js", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use the Math method in js" article.
1.min () and max () methods
Math.min () is used to determine the minimum value in a set of values. Math.max () is used to determine the maximum value in a set of values.
Alert (Math.min (2, 4, 3, 3, 6, 3, 3, 8, 0, 0, 1)); / / minimum alert (Math.max, 4, 7, 8, 3, 1, 9, 6, 0, 3, 2)); / / maximum
two。 Rounding method
Math.ceil () performs up rounding, that is, it always rounds the value up to the nearest integer
Math.floor () performs down rounding, that is, it always rounds the value down to the nearest integer
Math.round () performs standard rounding, that is, it always rounds the value to the nearest integer
For example:
Alert (Math.ceil); / 26alert (Math.floor); / 25alert (Math.floor); / 25alert (Math.floor); / / 25alert (Math.round); / 26alert (Math.round); / / 26alert (Math.round) / / 25
3.random () method
The Math.random () method returns a random number between 0 and 1, excluding 0 and 1. If you want to be larger than this range, you can apply the following formula:
Value = Math.floor (Math.random () * Total + first value)
For example:
Alert (Math.floor (Math.random () * 10 + 1)); / / randomly generate any number between 1 and 10
For (var I = 0; I
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.