25.18. The Math Object

The Math object does not correspond to an HTML element but is used for basic arithmetic operations. It supports substantially the same methods as does the java.lang.Math class in Java. You never make a new Math object, but instead you access the properties and methods through Math.propertyName or Math.methodName(...).

Properties

Using these constants is faster than recalculating them each time.

E This is e, the base used for natural logarithms.

LN10 This is ln(10), that is, loge(10).

LN2 This is ln(2), that is, loge(2).

LOG10E This is log10(e).

LOG2E This is lg(e), that is, log2(e).

PI This is π.

SQRT1_2 This is , that is, .

SQRT2 ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.