--- title: Math.tanh() slug: Web/JavaScript/Reference/Global_Objects/Math/tanh translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh ---
A função Math.tanh()
retorna a tangente hiperbólica de um número, que é:
Math.tanh(x)
x
Uma tangente hiperbólica de um número dado.
Because tanh()
is a static method of Math
, you always use it as Math.tanh()
, rather than as a method of a Math
object you created (Math
is not a constructor).
Math.tanh()
Math.tanh(0); // 0 Math.tanh(Infinity); // 1 Math.tanh(1); // 0.7615941559557649
This can be emulated with the help of the {{jsxref("Math.exp()")}} function:
Math.tanh = Math.tanh || function(x){ var a = Math.exp(+x), b = Math.exp(-x); return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b); }
Specification | Status | Comment |
---|---|---|
{{SpecName('ES2015', '#sec-math.tanh', 'Math.tanh')}} | {{Spec2('ES2015')}} | Initial definition. |
{{SpecName('ESDraft', '#sec-math.tanh', 'Math.tanh')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Math.tanh")}}