JavaScript Math.asin(): Arcsine Examples in Radians and Degrees

Tech reviewed: Deepak Prasad
JavaScript Math.asin(): Arcsine Examples in Radians and Degrees

JavaScript Math.asin() returns the arcsine—the angle in radians whose sine equals the given number. The argument must be between -1 and 1; otherwise the result is NaN. The returned angle is always in the range [-π/2, π/2]. Pair radians with degrees ↔ radians helpers when your inputs or labels are in degrees, and compare with JavaScript Math.acos() for the cosine inverse.

Tested On: The examples were tested with Node.js v20.18.1 on a Linux system. The same Math.asin() behavior works in modern browsers and JavaScript runtimes.


Math.asin Syntax

Unit circle diagram illustrating arcsine Math.asin principal range in radians

javascript
Math.asin(x)

x must be in the range -1 to 1. The return value is an angle in radians between -π / 2 and π / 2.


Method 1: Calculate arcsine with Math.asin()

javascript
const angle = Math.asin(0.5);

console.log(angle);

Output:

text
0.5235987755982989

The result is approximately π / 6 radians because the sine of π / 6 is 0.5.


Method 2: Convert Math.asin Result to Degrees

javascript
const radians = Math.asin(0.5);
const degrees = radians * (180 / Math.PI);

console.log(degrees);

Output:

text
30.000000000000004

The result is close to 30 degrees. The small extra decimal comes from floating-point precision.


Method 3: Check Boundary Values and NaN

Math.asin(-1) returns -π / 2, Math.asin(0) returns 0, and Math.asin(1) returns π / 2.

javascript
console.log(Math.asin(-1));
console.log(Math.asin(0));
console.log(Math.asin(1));

Output:

text
-1.5707963267948966
0
1.5707963267948966

Values outside -1 to 1 return NaN.

javascript
console.log(Math.asin(2));

Output:

text
NaN

Method 4: Compare Math.asin() and Math.sin()

Math.asin() is the inverse of Math.sin() for values in its output range.

javascript
const value = 0.5;
const angle = Math.asin(value);

console.log(Math.sin(angle));

Output:

text
0.5

This confirms that Math.asin(0.5) returns an angle whose sine is 0.5.


Common Questions About Math.asin

What is asin in math?

asin is arcsine, the inverse sine function. It returns the angle whose sine equals the input value.

Does Math.asin return radians or degrees?

Math.asin() returns radians. Convert to degrees with radians * 180 / Math.PI.

Why does Math.asin return NaN?

It returns NaN when the input is less than -1 or greater than 1.


Summary

JavaScript Math.asin() calculates arcsine and returns an angle in radians. Use it when you know a sine value and need the corresponding angle. The valid input range is -1 to 1; outside that range, Math.asin() returns NaN. Convert the radians result to degrees when presenting trigonometry output to users.


Official Documentation

Olorunfemi Akinlua

Boasting over five years of experience in JavaScript, specializing in technical content writing and UX design. With a keen focus on programming languages, he crafts compelling content and designs user-friendly interfaces to enhance digital …

  • JavaScript
  • Web Design