Math.cosh()
La funció Math.cosh()
retorna el cosinus hiperbòlic d'un nombre, això es pot expressar utilitzant la constant e:
Sintaxi
Math.cosh(x)
Paràmetres
x
- Un nombre.
Descripció
Com que que cosh()
és un mètode estàtic de Math
, sempre s'utilitza com a Math.cosh()
, en comptes de com a mètode d'una instància de Math
(Math
no és un constructor).
Exemples
Utilitzar Math.cosh()
Math.cosh(0); // 1
Math.cosh(1); // 1.5430806348152437
Math.cosh(-1); // 1.5430806348152437
Polyfill
Aquesta funció es pot emular amb l'ajuda de la funció Math.exp()
:
Math.cosh = Math.cosh || function(x) {
return (Math.exp(x) + Math.exp(-x)) / 2;
}
o bé utilitzant només una crida a la funció Math.exp()
:
Math.cosh = Math.cosh || function(x) {
var y = Math.exp(x);
return (y + 1 / y) / 2;
};
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Math.cosh' in that specification. |
Standard | Definició inicial. |
Compatibilitat amb navegadors
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | 38 | 25 (25) | No support | 25 | 7.1 |
Característica | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | No support | No support | 25.0 (25) | No support | No support | 8 |