one, Math.min () and Math.max (), respectively, to return the minimum and maximum values in the parameter
Cases:
Alert (Math.min (1,2,3))//output "1"
Alert (Math.max (1,2,3))//Output "3"
Second, Math.Abs (), return the absolute value of the parameter
Cases:
Alert (Math.Abs (-1))//output "1"
three, Math.random (), produces a random number from 0 to 1
Cases:
window.open ("http://www.***.com/index.shtml?t=" +math.random)//After the URL address plus a parameter with a value of a number that guarantees that the page will be pulled back from the server each time, instead of reading the cache.
iv. Math.floor ( ), Math.Round (), Math.ceil ()
Math.floor (): Rounds decimal down to an integer example: Alert (Math.floor (1.5))//output "1"
Math.Round (): The decimal standard rounded to an integer example: Alert (Math.Round (1.5))//Output "2"
Math.ceil (): Rounds decimal up to an integer: Alert (Math.Round (1.5))//Output "2"
Using these three functions is very handy when it comes to decimal computations, such as designing the following functions for decimal processing
Copy Code code as follows:
The function test (num,flag,bit)//parameter is the decimal "num" rounding standard to be passed in (-1, down; 0, standard 1 up) "flag" preserves decimal digits "bit"
{
var n=math.pow (10,bit);
Switch (flag)
{
Case-1:return Math.floor (num*n)/n;break;
Case 0:return Math.Round (num*n)/n;break;
Case 1:return Math.ceil (num*n)/n;
}
}