## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

### The Math Object

The Math object brings to JavaScript all the basic mathematical function-ality and constants you are likely to need.

Let's look at some examples of the Math object in action.

#### Using the PI Property

The π constant is one constant (equal to about 3.1415, although the numbers go on forever with the millionth number being a 1!) you might want to use, especially if you deal with circles. π returns the ratio of the circumference of a circle to its diameter. The following shows it in action as a simple circle area calculator using the mathematical formula Pi x r^2 or Pi x r x r (see Figure 9.1):

` <script language="JavaScript"> <!-- Cloaking device on! inpRadius = prompt("Enter the radius for your circle","Radius - digits only!"); alert(Math.PI ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required