--- title: Math.tanh() slug: Web/JavaScript/Reference/Global_Objects/Math/tanh tags: - ECMAScript 2015 - JavaScript - Referencia - metodo translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh original_slug: Web/JavaScript/Referencia/Objetos_globales/Math/tanh ---
La funcion Math.tanh()
devuelve la hyperbolica tangente de un numero, esto es
Math.tanh(x)
x
La hyperbolica tangente del numero obtenido.
Porque tanh()
es un metodo estatico de Math
, siempre se usa como Math.tanh()
, en lugar de ser un metodo de Math
objeto que creas (Math
no es un constructor).
Math.tanh()
Math.tanh(0); // 0 Math.tanh(Infinity); // 1 Math.tanh(1); // 0.7615941559557649
Esto puede ser emulado con ayuda de {{jsxref("Math.exp()")}} funcion:
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); }
Especificacion | Estado | Comentario |
---|---|---|
{{SpecName('ES2015', '#sec-math.tanh', 'Math.tanh')}} | {{Spec2('ES2015')}} |
Definicion inicial. |
{{SpecName('ESDraft', '#sec-math.tanh', 'Math.tanh')}} | {{Spec2('ESDraft')}} |
La compatibilidad de la tabla en esta pagina esta generada desde una structura data. Si quiers contribuir a la data, visita https://github.com/mdn/browser-compat-data y envianos un propuesta.
{{Compat("javascript.builtins.Math.tanh")}}