Use of Math Object in JavaScript

In this article I am going to explain about Math object in JavaScript.
  • 1548

JavaScript Math object

In JavaScript Math object use to perform all mathematics task. There are some method and properties of math object. There are following:-

Math object properties.

  • LN2 - Return natural logarithm of 2.
  • PI - Return PI.
  • SQRT2 - Return the squire root of 2.
  • LOG10E - Return the base10 logarithm of E.

Math object Method

  • abs(a) - Return absolute value of a.
  • sqrt(a) - Return squire root of a.
  • tan(a) - Return the target of angle.
  • round(a) - Return nearest integer of a.
  • sin(a) - Return the sine of a.
  • asin(a) - Return arcsine of a.
  • consin(a) - Return the consine of a.
  • pow(a,b) - Returns the value of x to the power of y
  • min(a,b,c,d......n) - Returns the number with the lowest value

Example

In following example we are using pow() method of math object.

<html>

<head>

    <script type="text/javascript">

        function Myfun() {

            var test = Math.pow(5, 3);

            alert(test);

        }

    </script>

</head>    

<body>

    <button onclick="Myfun()">

        Click</button>

</body>

</html>

 

Output


 math.gif

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

 

Categories

More Articles

© 2013 dotNetheaven. All rights reserved.