17.11.2015 Views

JavaScript_Succinctly

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 16 Math Function<br />

Conceptual overview of the built-in Math object<br />

The Math object contains static properties and methods for mathematically dealing with<br />

numbers or providing mathematical constants (e.g., Math.PI;). This object is built into<br />

<strong>JavaScript</strong>, as opposed to being based on a Math() constructor that creates math<br />

instances.<br />

Notes<br />

It might seem odd that Math starts with a capitalized letter since you do not instantiate<br />

an instance of a Math object. Do not be thrown off by this. Simply be aware that<br />

<strong>JavaScript</strong> sets this object up for you.<br />

Math properties and methods<br />

The Math object has the following properties and methods:<br />

Properties (e.g., Math.PI;):<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

E<br />

LN2<br />

LN10<br />

LOG2E<br />

LOG10E<br />

PI<br />

SQRT1_2<br />

SQRT2<br />

Methods (e.g., Math.random();):<br />

<br />

<br />

<br />

<br />

<br />

abs()<br />

acos()<br />

asin()<br />

atan()<br />

atan2()<br />

139

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!