Trigonometry-related operations

Often there is a need to use mathematical functions related to trigonometry, exponential, logarithmic, and so on. JavaScript provides native methods for that to make our work easy.

The following example code, which shows all trigonometry-related methods that are added to the Math object:

console.log(Math.sinh(0)); //hyberbolic sine of a valueconsole.log(Math.cosh(0)); //hyberbolic cosine of a valueconsole.log(Math.tanh(0)); //hyberbolic tangent of a valueconsole.log(Math.asinh(0)); //inverse hyperbolic sine of a valueconsole.log(Math.acosh(1)); //inverse hyperbolic cosine of a valueconsole.log(Math.atanh(0)); //inverse hyperbolic tangent of a valueconsole.log(Math.hypot(2, 2, 1));//Pythagoras theorem

The output ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.