The acosh() method computes the hyperbolic arc-cosine of the specified number and returns it.
Example
acosh() syntax
The syntax of the Math.acosh() method is:
Math.acosh(number)
Here, acosh() is a static method. Hence, we are accessing the method using the class name, Math.
acosh() Parameter
The acosh() method takes a single parameter:
number- a positive value whose hyperbolic arc-cosine is to be calculated
acosh() Return Value
The acosh() method returns:
- hyperbolic arc-cosine of the given positive argument
number - NaN (Not a Number) for zero, negative and non-numeric argument
Example 1: JavaScript Math.acosh() with Positive Numbers
In the above example, we have used the Math.acosh() method with
32(integer value) - results in 4.1586388532791674.5(floating-point value) - result in 2.1846437916051085
Example 2: Math.acosh() with Zero and Negative Numbers
In the above example, we have used the acosh() method with a negative number and zero. For both values, we get NaN as output.
Note: We can only use the acosh() method with positive numbers.
Example 3: Math.acosh() with Non-Numeric argument
In the above example, we have used the acosh() method with the string "Harry". Hence, we get NaN as output.
Recommended readings: