Movatterモバイル変換


[0]ホーム

URL:


  1. 개발자를 위한 웹 기술
  2. JavaScript
  3. JavaScript 참고서
  4. 표준 내장 객체
  5. Math
  6. Math.tanh()

This page was translated from English by the community.Learn more and join the MDN Web Docs community.

View in EnglishAlways switch to English

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 ⁨2015년 7월⁩.

Math.tanh() 함수는 쌍곡탄젠트 값을 반환합니다. 수식으로는 아래와 같습니다.

tanhx=sinhxcoshx=ex-e-xex+e-x=e2x-1e2x+1\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}

시도해 보기

console.log(Math.tanh(-1));// Expected output: -0.7615941559557649console.log(Math.tanh(0));// Expected output: 0console.log(Math.tanh(Infinity));// Expected output: 1console.log(Math.tanh(1));// Expected output: 0.7615941559557649

Syntax

js
Math.tanh(x);

파라미터

x

숫자.

반환 값

주어진 수의 쌍곡탄젠트 값

설명

tanh()Math의 정적 메서드이므로 사용자가 만든Math 객체의 메서드가 아닌 항상Math.tanh() 으로 사용합니다 (Math 는 생성자가 아닙니다.).

UsingMath.tanh()

js
Math.tanh(0); // 0Math.tanh(Infinity); // 1Math.tanh(1); // 0.7615941559557649

Polyfill

This can be emulated with the help of theMath.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® 2026 Language Specification
# sec-math.tanh

브라우저 호환성

함께 보기

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp