LILLY ROBOT |
Javascript has a built in Math Object, which has its own properties and methods. The table below shows the properties of the Math Object with a brief explanation.
Property | Explanation |
---|---|
E | Value of Euler's constant (E) - approximate value of 2.71828 |
LN2 | The natural logarithm of 2 - approximate value is 0.69315 |
LN10 | The natural logarithm of 10 - approximate value is 2.30259 |
LOG2E | The base 2 logarithm of E - approximate value is 1.442695 |
LOG10E | The base 10 logarithm of E - approximate value is 0.43429 |
PI | Represents the ratio of the circumference of a circle to its diameter - approximate value is 3.14 |
SQRT1_2 | The square root of 0.5 - approximate value is 0.70711 |
SQRT2 | The square root of 2 - approximate value is 1.41421 |
Displays
Displays
The table below shows the methods of the Math Object with a brief explanation.
Methods | Example | Explanation | Result |
---|---|---|---|
Math.abs() | Math.abs(-4.2) | returns the absolute value of -4.2 | |
Math.acos() | Math.acos(0.5) | returns the arc cosine of 0.5 | |
Math.asin() | Math.asin(0.5) | returns the arc sine of 0.5 | |
Math.atan() | Math.atan(3) | returns the arc tangent of 3 | |
Math.ceil() | Math.ceil(6.85) | rounds the number up to the nearest integer |
7 |
Math.cos() | Math.cos(2) | returns the cosine of 2 | |
Math.exp() | Math.exp(5) | means
e5 value of e is 2.718
returns the exponent value of 5
|
|
Math.floor() | Math.floor(6.85) | rounds the number down to the nearest integer | 6 |
Math.log() | Math.log(10) | returns the natural logarithm of 10 | |
Math.max() | Math.max(2,3,-1,5) | returns the largest number from the list |
5 |
Math.min() | Math.min(2,3,-1,5) | returns the smallest number from the list |
-1 |
Math.pow() | Math.pow(2,4) | means two to the power of 4 - (24) 2x2x2x2 | 16 |
Math.random() | Math.random() | returns a random number |
|
Math.round() | Math.floor(3.22) | rounds the number to the nearest integer | 3 |
Math.sin() | Math.sin(2) | returns the sine of 2 | |
Math.sqrt() | Math.sqrt(9) | returns the square root of 9 | 3 |
Math.tan() | Math.tan(45) | returns the tangent of 45(angle) |
Displays
Displays
Displays
Displays
Displays
Displays
Returns a number between 0 and 21
Displays
Returns a number between 1 and 22
Displays