Javascript Math

tutorial and example
tutorial and example

JavaScript Math

Math is build-in object that has properties and methods for mathematical constants and functions.

It allows you to perform mathematical tasks on numbers.

Syntax

  1. varpi_val = Math.PI;
  2. varsin_val = Math.sin(30);

Examples

Math.pow()

Math.pow(x,y) returns the value of x to the power of y:

Try Now

Output

Math.sqrt()

Math.sqrt(x) returns the square root of x

Try Now

Output

Math.ceil()

Math.ceil(x) returns the value of x rounded up to its nearest integer:

Try Now

Output