What are JavaScript Math Functions?

JavascriptWeb DevelopmentFront End Technology

The following are some of the Math Functions in JavaScript −

S.No
Method & Description
 1
abs()
Returns the absolute value of a number.
2
acos()
Returns the arccosine (in radians) of a number.
3
asin()
Returns the arcsine (in radians) of a number.
4
atan()
Returns the arctangent (in radians) of a number.
5
atan2()
Returns the arctangent of the quotient of its arguments.

6
ceil()
Returns the smallest integer greater than or equal to a number.

Example

Let’s see an example of abs() Math function in JavaScript. The Math() function returns the absolute value of a number −

<html>
   <head>
      <title>JavaScript Math abs() Method</title>
   </head>
   <body>
      <script>
         var value = Math.abs(-1);
         document.write("First Value : " + value );
         
         var value = Math.abs(5);
         document.write("<br />Second Value : " + value );
         
         var value = Math.abs("string");
         document.write("<br />Third Value : " + value );
      </script>
   </body>
</html>
raja
Published on 16-Feb-2018 12:01:20
Advertisements