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
Output of the following code snippet is as follows