Math.tanh()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Math.tanh()
함수는 쌍곡탄젠트 값을 반환합니다. 수식으로는 아래와 같습니다.
시도해보기
console.log(Math.tanh(-1));
// Expected output: -0.7615941559557649
console.log(Math.tanh(0));
// Expected output: 0
console.log(Math.tanh(Infinity));
// Expected output: 1
console.log(Math.tanh(1));
// Expected output: 0.7615941559557649
Syntax
js
Math.tanh(x);
파라미터
x
-
숫자.
반환 값
주어진 수의 쌍곡탄젠트 값
설명
tanh()
은 Math
의 정적 메서드이므로 사용자가 만든 Math
객체의 메서드가 아닌 항상 Math.tanh()
으로 사용합니다 (Math
는 생성자가 아닙니다.).
예
Using Math.tanh()
js
Math.tanh(0); // 0
Math.tanh(Infinity); // 1
Math.tanh(1); // 0.7615941559557649
Polyfill
This can be emulated with the help of the Math.exp()
function:
js
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 |
---|
ECMAScript® 2025 Language Specification # sec-math.tanh |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tanh |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.