Introduction JavaScript Math.Asinh() Function with Examples

Introduction JavaScript Math.Asinh() Function with Examples

In JavaScript, asinh() is a function that is used to return the hyperbolic arc sine (also called inverse hyperbolic sine) of a number. Because the asinh() function is a static function of the Math object, it must be invoked through the placeholder object called Math.

In JavaScript, asinh() is a function that is used to return the hyperbolic arc sine (also called inverse hyperbolic sine) of a number. Because the asinh() function is a static function of the Math object, it must be invoked through the placeholder object called Math.

Syntax:

Math.sinh(p)

Parameter(s):

  • p - whose hyperbolic arcsine value is to be determined.

Return value:

  • It returns the calculated value of the hyperbolic sine of the number.

Polyfill

Math.asinh = Math.asinh || function(x) {
if(x === -Infinity){
 return x;
 } else {
      return Math.log(x + Math.sqrt(x*x+1));
 }
};

Browser Support:

  • Google Chrome
  • Firefox
  • Opera
  • Safari
  • Opera for Android
  • Safari on iOS
  • Android webview
  • Chrome for Android
  • Edge Mobile
  • Firefox for Android
  • Samsung Internet
  • Node.js

Math.Asinh() Method with Example

Example 1

Let's take a look at an example of how to use the asinh() function in JavaScript.

console.log(Math.asinh(1));
console.log(Math.asinh(1.5));
console.log(Math.asinh(-2));

Output

0.881373587019543
1.1947632172871094
-1.4436354751788103
  • In this example, the first output to the console log returned 0.881373587019543 which is the hyperbolic arc sine of 1.
  • The second output to the console log returned 1.1947632172871094 which is the arc sine of 1.5.
  • The third output to the console log returned -1.4436354751788103 which is the arc sine of -2.

Example 2

It is an error case because complex number can not be taken as the parameter of the function only integer value can be taken as the parameter.

// complex number can not be calculated as the hyperbolic sine. 
console.log(Math.sinh(1 + 2i)); 

Output

Error: Invalid or unexpected token

Example 3

The following code demonstrates the use of polyfill for this method.


var a = -1;
var b = 2;
var c = 1;
var d = 0;

function myfunc(x) {
  if (x === -Infinity) return x;
  else return Math.log(x + Math.sqrt(x * x + 1));
}

console.log(Math.asinh(a));
console.log(Math.asinh(b));
console.log(Math.asinh(c));
console.log(Math.asinh(d));

console.log(myfunc(a));
console.log(myfunc(b));
console.log(myfunc(c));
console.log(myfunc(d));

Output


-0.881373587019543
1.4436354751788103
0.881373587019543
0
-0.8813735870195428
1.4436354751788103
0.8813735870195429
0

Javascript Math.asinh() method is used to return the hyperbolic arc-sine of a number. Thanks for reading !

javascript js developer

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Hire React Js Developer from Expert React JS Development Company

Are you looking to [hire React JS developer](https://www.mobiwebtech.com/react-js-development-company/ "hire React JS developer") from a prestigious and reliable React JS development company? Visit at Mobiweb Technologies here we have a big team...

Top Node.js Development Companies and Expert NodeJS Developers

A thoroughly researched list of top NodeJS development companies with ratings & reviews to help hire the best Node.JS developers who provide development services and solutions across the world. List of Leading Node.js development Service Providers...

How to Hire Node.js Developers And How Much Does It Cost?

A Guide to Hire Node.js Developers who can help you create fast and efficient web applications. Also, know how much does it cost to hire Node.js Developers.