Using Math Object in Java Script

Using Math Object in Java Script

We can take help of Math object to perform mathematical operation. Sometime we want to perform mathematical calculation on client side then we use concept of java script Math object. Java Script math object provides some built in function to perform mathematical task. In this demonstration we learn that how to use mathematical function in java script.

Some commonly used Math function in Java Script

ØMath.PI:Math.PI property gives value of PI.

ØMath.sqrt(<value>): Math.sqrt(<value>) method returns square root of number passed to its parameter.

ØMath.round(<double value>): Math.round(<double value>) returns an round of value of given decimal value. Such as round of value of 5.7 is 6.

ØMath.random():Math.random() method return random number which is greater than 0 and less than 1.

Following function provides a demonstration to use Java Script Math object