This site runs best with JavaScript enabled.

Math

Kevin Beck

July 03, 2019


It seems like I am simply re-posting MDN in all my posts, I kind of am. But first it’s an amazing source of information and secondly re posting all the content is a good way to learn it all.

'Math is a built-in object that has properties and methods for mathematical constants and functions.' MDN

The top methods I use are:

Math.ceil(x)

Returns the smallest integer greater than or equal to a number.

Math.floor(x)

Returns the largest integer less than or equal to a number.

Math.round(x)

Returns the value of a number rounded to the nearest integer.

Alongside these I almost always use:

parseFloat(value)

I use it to make sure values passed in are numbers.

Source