On this page

Math class in JavaScript

Enrico Hochkoeppler Profile

By Enrico Hochkoeppler

Web Developer & TutoriaLibre Founder

Properties​

Some properties of the Math object:

Property****DescriptionEEuler’s constantLN2Natural log of 2 [ln(2)]LN10ln(10)LOG2Elog2(e)LOG10Elog10(e)PIPi (3.14….)

Methods​

Some methods:

Method****Descriptionabs(x)absolute valueacos(x)arccosasin(x)arcsinatan(x)atan2(y, x)arctangent of the quotient of its argumentsceil(x)rounds up to the nearest integercos(x)sin(x)exp(x)floor(x)rounds down to the nearest integerlog(x)ln(x)max(x,y,…)min(x,y,…)sqrt(x)tan(x)random()random number between 0 and 1 (1 not included) [0, 1[

Example: generate a random integer number between 1 and 10


Math.ceil(Math.random() * 10);

Found this helpful? Share the knowledge...

... or support this project to keep it alive!

Buy Me a Coffee

Previous

Associative arrays

Next

Date