C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Math asin() methodThe JavaScript math asin() method returns the arcsine of the given number in the form of radians. The asin() method must be in the range -1 to 1, otherwise it returns NaN. Syntax
The asin() method is represented by the following syntax: Math.asin(num) Parameter
num - A number. ReturnThe arcsine of the number. JavaScript Math asin() method example
Here, we will understand asin() method through various examples. Example 1Let's see a simple example of asin() method. <script> document.writeln(Math.asin(-1)+"<br>"); document.writeln(Math.asin(0)+"<br>"); document.writeln(Math.asin(0.5)+"<br>"); document.writeln(Math.asin(1)); </script> Output: -1.5707963267948966 0 0.5235987755982989 1.5707963267948966 Example 2Let's see some cases where asin() method returns NaN. <script> document.writeln(Math.asin()+"<br>"); document.writeln(Math.asin(2)+"<br>"); document.writeln(Math.asin(-2)); </script> Output: NaN NaN NaN Example 3Here, you can test asin() method with your own test cases.
<script>
function display()
{
var x=document.getElementById("num").value;
document.getElementById("result").innerHTML=Math.asin(x);
}
</script>
<form>
Enter a number: <input type="text" id="num">
<input type="button" onclick="display()" value="submit">
</form>
<p><span id="result"></span></p>
Next TopicJavaScript Math
|