DEV Community

Pratik Lochawala
Pratik Lochawala

Posted on • Edited on

Most useful javascript math functions

abs

Math.abs function returns the absolute value of a number

carbon (22).png

ceil

Math.ceil function rounds a number up to the next largest integer

carbon (23).png

floor

Math.floor function rounds a number down to its nearest integer

carbon (25).png

round

Math.round function rounds a number to its nearest integer

carbon (24).png

trunc

Math.trunc function returns the integer part of a number

carbon (26).png

max

Math.max function returns the number with the largest value

carbon (55).png

min

Math.min function returns the number with the lowest value

carbon (54).png

pow

Math.pow function returns the base to the exponent power

carbon (31).png

sqrt

Math.sqrt function returns the square root of a number

carbon (32).png

cbrt

Math.cbrt function returns the cubic root of a number

carbon (33).png

random

Math.random return random number between 0 to 1

carbon (35).png

Bonus

sign

Math.sign return an argument is negative, positive or NaN

carbon (34).png

Wrapping up!

Share this blog with your friends 👩🏼‍🤝‍🧑🏼 and developers 👨‍💻 you know and let them know these

Your feedback and comments are very important to me. 💌

Get in touch 🤜🤛

Instagram

Top comments (0)