Categories
Web development

JavaScript Math.asin() & Math.asinh()

JavaScript Math.asin() & Math.asinh()

The JavaScript Math.asin() returns the arcsine of a number as a value between -PI/2 and PI/2 radians.

Syntax:

Math.asin(number)

Example:

<!DOCTYPE html>
<html>
<body>

<button onclick="asinExample()">Try it</button>
<p id="ex-1"></p>

<script>
function asinExample() {
  document.getElementById("ex-1").innerHTML = Math.asin(0.7);
}
</script>

</body>
</html>

Output:

Click the button to display the arcsine of 0.7


Note: If the parameter x is outside the range -1 to 1, the browser will return NaN.

The JavaScript Math.asinh() returns the hyperbolic arcsine of a number.

Syntax:

Math.asinh(x)

Example:

<!DOCTYPE html>
<html>
<body>

<button onclick="asinhExample()">Try it</button>
<p id="ex-2"></p>

<script>
function asinhExample() {
  document.getElementById("ex-2").innerHTML = Math.asinh(1);
}
</script>

</body>
</html>

Output:

Click the button to display the hyperbolic arcsine of 1


Enjoy coding!

Read also:

JavaScript Math Object

JavaScript Math.sin()

JavaScript Math Object Properties