CKTIS / JavaScript
Math.asin: inverse sine
Math.asin returns the inverse sine of a number in radians, with real domain -1 through 1 and result -π/2 through π/2.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
Math.asin(x)Math.asin(x) applies ToNumber and computes the principal inverse sine. For x in [-1, 1], the result lies in [-π/2, π/2] radians: asin(1) is approximately π/2 and asin(-1) approximately -π/2. It preserves the sign of zero: asin(+0) is +0 and asin(-0) is -0.
A finite value outside [-1, 1], ±Infinity, NaN, or a missing argument produces NaN. A numeric string is converted by ToNumber, while a Symbol or BigInt throws TypeError; an object can invoke valueOf or toString. The result is a Number and its approximation may be implementation-dependent.
The function is not a constructor and has been standard since ECMAScript 1. Its result is in radians; degrees are radians * 180 / Math.PI. When input comes from a computed normalized component, clamp it to [-1, 1] so rounding error does not turn a valid angle into NaN.
Examples
function pitchFromVerticalComponent(y) {
return Math.asin(Math.max(-1, Math.min(1, y)));
}
const angle = pitchFromVerticalComponent(0.5);
console.log(angle.toFixed(6), (angle * 180 / Math.PI).toFixed(1));
console.log(Math.asin(1).toFixed(6), Math.asin(-1).toFixed(6));
console.log(Object.is(Math.asin(-0), -0));
console.log(Number.isNaN(Math.asin(1.1)), Number.isNaN(Math.asin()));
try { Math.asin(1n); } catch (error) { console.log(error instanceof TypeError); }Result
0.523599 30.0 1.570796 -1.570796 true true true true