JavaScript Math sinh() method is used to calculate the hyperbolic sine of a number.
Formula
Syntax
Math.sinh(num)
Parameters
num(required): It is the number for which you want to calculate the hyperbolic sine.
Return Value
Return the hyperbolic sine of a number.
If the passed value is non-numeric or empty, the method returns NaN.
Visual Representation
Example 1: How to Use Math sinh() Method
let a = 2; //positive number
let b = -2; //negative number
let c = 3.7; //float number
let d = 0;
console.log(Math.sinh(a));
console.log(Math.sinh(b));
console.log(Math.sinh(c));
console.log(Math.sinh(d));
Output
3.626860407847019
-3.626860407847019
20.21129041679853
0
Example 2: Handling empty and Non-numeric value
console.log(Math.sinh("Ronaldo")); //non-numeric value
console.log(Math.sinh()); //empty value
Output
NaN
NaN
Example 3: Passing Infinity
console.log(Math.sinh(Infinity));
console.log(Math.sinh(-Infinity));
Output
Infinity
-Infinity
Browser Compatibility
- Google Chrome 38 and above
- Firefox 25 and above
- Opera 25 and above
- Safari 8 and above
- Edge 12 and above
Ankit Lathiya is a Master of Computer Application by education and Android and Laravel Developer by profession and one of the authors of this blog. He is also expert in JavaScript and Python development.