API · JavaScript

JavaScript Math.asin() Method

The Math.asin() method returns the inverse sine (arcsine) of a number as a radian angle from -π/2 through π/2.

On this page

The JavaScript Math.asin() function calculates the inverse sine, also called arcsine, of a number. It returns an angle in radians in the principal range from -π/2 through π/2. For example, the inverse sine of 1 is π/2, while the inverse sine of 0 is 0.

What Math.asin() Returns

Sine maps an angle to a number from -1 to 1; Math.asin() works in the opposite direction by taking a number and returning its principal angle. Since many angles can have the same sine, JavaScript selects the result between -π/2 and π/2, inclusive. The returned value is a JavaScript number measured in radians, not degrees. If your application needs degrees, convert the result with angle * 180 / Math.PI.

The input domain is also inclusive: values from -1 through 1 have a real principal inverse-sine result. A value below -1 or above 1 produces NaN, which indicates that the input is outside this function’s real-valued domain. Check the input range before using the result in later calculations or displaying it as an angle.

Syntax of Math.asin()

The call form is Math.asin(num). It calls the static asin() function on JavaScript’s built-in Math object. Replace num with the numeric value whose inverse sine you need; there is no Math instance to create.

Parameters and Return Value

num is the number to evaluate. For a real angle result, pass a value in the inclusive range -1 to 1. The function returns a number in radians from -π/2 to π/2. The endpoint inputs map to the corresponding negative or positive endpoint angles, and 0 maps to 0.

Inputs less than -1 or greater than 1 return NaN. This is a returned numeric value, so code can detect it with Number.isNaN(result) and choose how to handle an out-of-domain input. Do not treat NaN as an angle or as a valid value for subsequent trigonometric calculations. For a valid input such as 0.5, the result is approximately 0.5236 radians, or π/6; use the returned number directly in JavaScript calculations rather than rounding it prematurely. Applying Math.sin() to a valid Math.asin() result recovers the input, subject to floating-point precision.

Examples

The first example uses both endpoints of the supported interval and its midpoint. It prints the radian result for each input:

Run this example:

const inputs = [-1, 0, 1]
for (const value of inputs) {
  console.log(Math.asin(value))
}
-1.5707963267948966
0
1.5707963267948966

The endpoint results correspond to -π/2 and π/2 radians, and the middle result is 0. To display these angles in degrees, multiply each returned value by 180 / Math.PI.

The next example illustrates the behavior for values outside the supported interval. It prints NaN for each input:

const inputs = [-3, 3]
for (const value of inputs) {
  const result = Math.asin(value)
  console.log(Number.isNaN(result) ? 'NaN' : result)
}
NaN
NaN

Both inputs are outside -1 through 1, so each call returns NaN. The check makes that result visible as text and can be adapted to show a validation message or skip a calculation. For additional API details, see the linked MDN reference above.