How to use acos in JavaScript

In this article, I will explain use of acos() method in JavaScript.
  • 1617

JavaScript acos() Method

  • acos() method of math object returns the arccosine in radians of a number.

  • acos method returns a numeric value between 0 and pi radians for x between -1 and 1.

  • In acos() method, if x value of number is outside this range, it returns NaN.

Syntax

Math.acos(x)

  • x is a Required number

Example

In the following example show to acos() method returns the arccosine of numbers.

<!DOCTYPE html>

<html>

<body>

<h3 style="background-color:Silver">acos() Method Example</h3>

<p id="demo">Click the button to display the arccosine of 0.8</p>

<button onclick="myFunction()">Click On</button>

<script type="text/javascript">

    function myFunction() {

        document.getElementById("demo").innerHTML = Math.acos(0.8);

    }

</script>

</body>

</html>

Output1

acos 1.jpg 

Output2

acos 2.jpg

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

© 2019 DotNetHeaven. All rights reserved.