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
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()
const angle = Math.asin(0.5);
console.log(angle);Output:
0.5235987755982989The result is approximately π / 6 radians because the sine of π / 6 is 0.5.
Method 2: Convert Math.asin Result to Degrees
const radians = Math.asin(0.5);
const degrees = radians * (180 / Math.PI);
console.log(degrees);Output:
30.000000000000004The 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.
console.log(Math.asin(-1));
console.log(Math.asin(0));
console.log(Math.asin(1));Output:
-1.5707963267948966
0
1.5707963267948966Values outside -1 to 1 return NaN.
console.log(Math.asin(2));Output:
NaNMethod 4: Compare Math.asin() and Math.sin()
Math.asin() is the inverse of Math.sin() for values in its output range.
const value = 0.5;
const angle = Math.asin(value);
console.log(Math.sin(angle));Output:
0.5This 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.
