There are many JavaScript that do not have to instantiate the built-in objects, as they have been instantiated, as described earlier in object,array,string. Then there are two single built-in objects: Global and math. The global object can be said to be a special object because you cannot see his presence, and all global scope-defined properties and functions are properties of the global object.
Here's a discussion of the Math object the Math object provides much faster execution than other computational methods, and also provides properties and methods to assist in the completion of these calculations.
min () and Max ()This can be used to determine the maximum minimum value in a set of arrays, for example: Var Max=math.max (3,3,4,5,2,6,1,5), or the Apply () method if you are looking for the maximum or minimum value in the array, for example: var nums = [5, 6, 4, 4, 2, 1, 6, 4, 9, 4, 5, 4];var Max =math.max.apply (math,nums); Max value is 9 here is a trick, the key is the Math object as the first parameter of apply (), so that the correct setting of this value.
Rounding MethodMath.ceil (): Rounded up; Math.floor (): Rounded down; Math.Round (): Quasi-rounding, always rounding the value to the nearest integer.
The random () methodThe Math.random () method returns a random number between 0 and 1, excluding 0 and 1. With the following formula, you can use Math.random () to randomly select a value from within a range of certificatesRandom value = Math.floor (Math.random () * Total number of possible values + first possible value);
Other calculation methodsMath.Abs (x) returns the X absolute value math.exp (x) returns the NUM power of MATH.E Math.log (x) returns the X natural logarithm Math.pow (x) returns power times x Power math.sqrt (x) returns X Square root Math.acos (x) returns the inverse cosine of x math.asin (x) returns the inverse sine of x math.atan (x) returns the inverse tangent of x math.atan2 (y,x) returns the inverse tangent value of y/x math.cos (x) returns X Cosine Math.sin (x) returns the sinusoidal value of x Math.tan (x) returns the tangent of X
JavaScript reference types-built-in objects (Math object)