Math in JS

Math is a built-in JavaScript object that provides numeric constants and utility methods.

Constants

console.log(Math.PI)
console.log(Math.E)

Common Methods

MethodUse
Math.round(x)nearest integer
Math.floor(x)round down
Math.ceil(x)round up
Math.trunc(x)remove decimal part
Math.pow(x, y)exponent
Math.sqrt(x)square root
Math.abs(x)absolute value
Math.max(x, y, z)largest value
Math.min(x, y, z)smallest value