Math acos() Method - Javascript Math

Javascript examples for Math:acos

Description

The acos() method returns the arccosine of a number as a value value between 0 and PI radians.

Parameter Values

Parameter Description
x Required. A number

Return Value:

A Number, from 0 to PI, or NaN if the value is outside the range of -1 to 1

The following code shows how to Return the arccosine of a number:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p>Click the button to display the arccosine of 0.5</p>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//w w  w .ja  v a 2  s. c o  m
    document.getElementById("demo").innerHTML = Math.acos(0.5);
}
</script>

</body>
</html>

Related Tutorials