Math [FF, IE 3]

The math object contains numerous properties and methods. Except where noted, all of these properties and methods work in Firefox, IE 3, and more recent browsers, and all the properties are read-only. Because most of the methods and properties are self-explanatory, I will give few examples. I'll round all numbers to the sixth decimal point.

Properties

E

e, Euler's constant, the base of natural logarithms (2.718282)

LN2

Natural log of 2 (0.693147)

LN10

Natural log of 10 (2.302585)

LOG2E

Base 2 log of e (1.442695)

LOG10E

Base 10 log of e (0.434294)

PI

Pi (3.141593)

SQRT2

Square root of 2 (1.414214)

Methods

abs()

Absolute value of the argument, for example, var ab_value = Math.abs(-10); sets ab_value to 10

acos()

Arc cosine of the argument in radians ...

Get The Book of JavaScript, 2nd 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.