What is the use of Math Object in JavaScript? [Resolved]

Posted by Programmer123 under JavaScript on 9/24/2013 | Points: 10 | Views : 1037 | Status : [Member] | Replies : 4
What is the use of Math Object in JavaScript?

Responses

Posted by: Bandi on: 9/25/2013 [Member] [MVP] Platinum | Points: 50
 0 Math object in javascript: The Math object allows you to perform mathematical tasks. The Math object includes several mathematical constants and methods. Syntax for using properties/methods of Math: ```var x=Math.PI; var y=Math.sqrt(16); ``` Note: Math is not a constructor. All properties and methods of Math can be called by using Math as an object without creating it. You may reference these constants from your JavaScript like this: ```Math.E Math.PI Math.SQRT2 Math.SQRT1_2 Math.LN2 Math.LN10 Math.LOG2E Math.LOG10E``` Example code: ```document.write(Math.round(4.7)); -- 5 document.write(Math.random()); -- any random value 0.3121296588253678 ``` The following example uses the floor() and random() methods of the Math object to return a random number between 0 and 10: `document.write(Math.floor(Math.random()*11));` Script for getting random number <10 using JavaScript: ``` ``` References: http://www.cev.washington.edu/lc/CLWEBCLB/jst/js_math.html http://www.javascriptkit.com/javatutors/math.shtml Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gifProgrammer123, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Allemahesh on: 9/25/2013 [Member] [MVP] Silver | Points: 50
 0 The math object provides you properties and methods for mathematical constants and functions.`var x = Math.PI; // Returns PIvar y = Math.sqrt(16); // Returns the square root of 16var z = Math.sin(90); Returns the sine of 90` Happy Coding,If it helps you or directs U towards the solution, MARK IT AS ANSWERProgrammer123, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Murugavelmsc on: 9/25/2013 [Member] Starter | Points: 25