Categories
JavaScript Web development

JavaScript Math.acosh()

JavaScript Math.acosh()

The JavaScript Math.acosh() returns the hyperbolic arccosine of a number.

Syntax:

Math.acosh(x)

Example:

<!DOCTYPE html>
<html>
<body>

<button onclick="acoshExample()">Try it</button>
<p id="ex-1"></p>

<script>
function acoshExample() {
  document.getElementById("ex-1").innerHTML = Math.acosh(2);
}
</script>

</body>
</html>

Output:

Click the button to display the hyperbolic arccosine of 2


If the x is less than 1, the method will return NaN:

<!DOCTYPE html>
<html>
<body>

<button onclick="acoshNan)">Try it</button>
<p id="ex-2"></p>

<script>
function acoshNan() {
  document.getElementById("ex-2").innerHTML = Math.acosh(0.7);
}
</script>

</body>
</html>

Output:

Click the button to display the hyperbolic arccosine of 0.7


Enjoy coding!