JavaScript Tutorial

The language for programming web pages.

JS Math

JavaScript Math

The JavaScript Math object allows you to perform mathematical tasks on numbers. Math is not a constructor — all properties and methods are static.

Common Math Methods:

  • Math.round() — Round to nearest
  • Math.ceil() — Round up
  • Math.floor() — Round down
  • Math.abs() — Absolute value
  • Math.max() / Math.min()
  • Math.random() — 0 to 1 random
  • Math.sqrt() — Square root
  • Math.pow() — Power
  • Math.PI — 3.14159...

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics