JavaScript Math (arithmetic) Object
Role Math (arithmetic) objects is: perform common arithmetic tasks.
Online examples
round ()
How to use the round ().
random ()
How to use the random () to return a random number between 0-1.
max ()
How to use a larger count max () to return the two given. (Before ECMASCript v3, which only two parameters.)
min ()
How to use min () to return the two numbers given in smaller numbers. (Before ECMASCript v3, which only two parameters.)
Complete Math Object Reference
We provide JavaScript Math object reference manual , which includes all properties and methods can be used for arithmetic object.
The manual contains a detailed description and relevant examples for each of the properties and methods.
Math Object
Role Math (arithmetic) objects are: to perform common arithmetic tasks.
Math object provides a variety of types and numerical calculation functions. Before using this object without having to define it.
Use Math attribute / method syntax:
var y = Math.sqrt (16);
Note: Math object does not use this object before it is defined.
Numerical calculation
JavaScript provides 8 kinds of objects that can be accessed Math Operators values:
You can refer to the following Javascript constant use:
Math.PI
Math.SQRT2
Math.SQRT1_2
Math.LN2
Math.LN10
Math.LOG2E
Math.LOG10E
Arithmetic method
In addition to objects that can be accessed Math count value, there are several functions (methods) can be used.
The following example uses the method of the Math object to round a number to round.
The code above outputs:
The following example uses the Math object's random () method to return a random number between 0 and 1:
The code above outputs:
The following example uses the Math object floor () method and random () to return a random number between 0 and 11, between:
The code above outputs: