Math Operations

JavaScript has a built-in Math object that provides functionality for extended mathematical operations. The Math object has property values, listed in Table 2.2, that contain the most common constants. You can access the Math object directly from your JavaScript code. For example, to get the value of pi, you would use the following:

Math.PI

Image

Table 2.2 Math Object Properties

The Math object also includes several methods that allow you to apply higher math operations. The following sections provide phrases for those operations.

Get jQuery and JavaScript Phrasebook 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.