Math-in-a-box with the Math Object

The Math Object is a built-in object in Javascript that provides easy access to commonplace mathematical constants and methods. Things like finding the square root of 36, rounding 1.7 upwards, among others.

All properties and methods of the Math object are static and can therefore be accessed directly from the prototype without having to create a new instance of the object.

The constants available in the Math object are:

Some of the methods available in the Math object:

Using the Math Object to create a random number generator

As an example, here’s the floor() and the random() methods used in combination to create a random number generator.

A list of all methods and their definitions can be found here.

Other posts about:
You're subscribed!
Oops! Something went wrong while submitting the form.