The JavaScript cosh function is one of the Math functions that is useful to calculate the trigonometry hyperbolic Cosine for a specified expression. The syntax of the cosh Function is:
Math.cosh(number);
HINT: We can get the same result using the JavaScript EXP formula below.
(Math.exp(number) + Math.exp(-number)) / 2
JavaScript cosh Function Example
In this example, we are going to find the JS hyperbolic Cosine values for different data types and display the output. Please refer to the JavaScript cos function from the Learn JavaScript page to understand the Cosine Function.
<!DOCTYPE html>
<html>
<head>
<title> Example </title>
</head>
<body>
<h1> JavaScriptCOSHFunction </h1>
<p id = "Pos"></p>
<p id = "Neg"></p>
<p id = "Dec"></p>
<p id = "Neg_Dec"></p>
<p id = "Str"></p>
<p id = "Exp"></p>
<p id = "Null"></p>
<p id = "Multi"></p>
<script>
document.getElementById("Pos").innerHTML = Math.cosh(1);
document.getElementById("Neg").innerHTML = Math.cosh(-2);
document.getElementById("Dec").innerHTML = Math.cosh(4.45);
document.getElementById("Neg_Dec").innerHTML = Math.cosh(-2.75);
document.getElementById("Str").innerHTML = Math.cosh("JavaScript");
document.getElementById("Null").innerHTML = Math.cosh(null);
document.getElementById("Multi").innerHTML = Math.cosh(2 + 9 - 7);
</script>
</body>
</html>
TIP: Please refer to the cos() and acosh() functions from the JavaScript Math functions article for the hyperbolic arc cosine values.
