C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Math tanh() methodThe JavaScript math tanh() method returns the hyperbolic tangent of the given number. SyntaxThe tanh() method is represented by the following syntax: The tanh() method is represented by the following syntax: Parameternum - A number. ReturnThe hyperbolic tangent of a number. JavaScript Math tanh() method exampleHere, we will understand tanh() method through various examples. Example 1Let's see a simple example of tanh() method. <script> document.writeln(Math.tanh(-1)+"<br>"); document.writeln(Math.tanh(0)+"<br>"); document.writeln(Math.tanh(0.5)+"<br>"); document.writeln(Math.tanh(2)); </script> Output: -0.7615941559557649 0 0.46211715726000974 0.9640275800758169 Example 2Here, you can test tanh() method with your own test cases. <script> function display() { var x=document.getElementById("num").value; document.getElementById("result").innerHTML=Math.tanh(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
|