JavaScript Math asinh()

The asinh() method computes the hyperbolic arcsine of the specified number and returns it.

Example

// hyperbolic arcsine of 5
let number = Math.asinh(5);
console.log(number); 

// Output: 2.3124383412727525

asinh() syntax

The syntax of the Math.asinh() method is:

Math.asinh(number)

Here, asinh() is a static method. Hence, we are accessing the method using the class name, Math.


asinh() Parameter

The asinh() method takes a single parameter:

  • number - whose hyperbolic arcsine is to be calculated

asinh() Return Value

The asinh() method returns:

  • hyperbolic arcsine of the given argument number
  • NaN (Not a Number) for a non-numeric argument

Example 1: JavaScript Math.asinh()

// hyperbolic arcsine of a negative number let number2 = Math.asinh(-5);
console.log(number2);
// hyperbolic arcsine of zero let number1 = Math.asinh(0);
console.log(number1);
// hyperbolic arcsine of a positive number let number3 = Math.asinh(32);
console.log(number3); // Output: // -2.3124383412727525 // 0 // 4.15912713462618

In the above example, the Math.asinh() computes the hyperbolic arcsine of

  • -5 (negative number) - results in -2.3124383412727525
  • 0 (zero) - results in 0
  • 32 (positive number) - results in 4.15912713462618

Example 2: Math.asinh() with Infinity

// asinh() with positive infinity let number1 = Math.asinh(Infinity);
console.log(number1); // Output: Infinity
// asinh() with negative infinity let number2 = Math.asinh(-Infinity);
console.log(number2); // Output: -Infinity

Example 3: Math.asinh() with Non-Numeric argument

let string ="Harry";
// asinh() with a string argument let value = Math.asinh(string);
console.log(value); // Output: NaN

In the above example, we have tried to calculate the hyperbolic arcsine value of the string "Harry". That's why we get NaN as the output.


Recommended readings: