JavaScript Math.asin() Method

  1. Syntax of JavaScript Math.asin() Method
  2. Example Codes: Use the Math.asin() Method
  3. Example Codes: Use the Math.asin() Method With Different Ranges
JavaScript Math.asin() Method

The JavaScript Math.asin() method returns a numeric value representing the opposite sine of a number in radians. The value is between -PI/2 to PI/2, and the range is -1 to 1.

Syntax of JavaScript Math.asin() Method

Math.asin(num) 

Parameters

num The parameter num refers to a numeric value that ranges will be -1 to 1.

Return

The Math.asin() method returns the opposite sine of a number in radians from a value between -PI/2 to PI/2. This method will return NaN if something is passed that is less than -1 or greater than 1.

Example Codes: Use the Math.asin() Method

const result1 = Math.asin(-1) const result2 = Math.asin(0) const result3 = Math.asin(1)  console.log(result1) console.log(result2) console.log(result3) 

Output:

-1.5707963267948966 0 1.5707963267948966 

We took three different numbers, -1, 0, and 1, and passed them as the parameter of the Math.asin() method. This method returned the opposite sine of these numbers in radians.

Example Codes: Use the Math.asin() Method With Different Ranges

const result1 = Math.asin(-3) const result2 =Math.asin(3)  console.log(result1) console.log(result2) 

Output:

NaN NaN 

This method returns NaN for both cases. The reason is that for the first case, the number is smaller than -1, and for the second case, the number is greater than 1.

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
MD Niaz Rahman Khan avatar MD Niaz Rahman Khan avatar

Niaz is a professional full-stack developer as well as a thinker, problem-solver, and writer. He loves to share his experience with his writings.

LinkedIn

Related Article - JavaScript Math