Math

Math는 수학적인 상수와 함수를 위한 속성과 메서드를 가진 내장 객체입니다. 함수 객체가 아닙니다.

MathNumber 자료형만 지원하며 BigInt와는 사용할 수 없습니다.

설명

다른 전역 객체와 달리 Math는 생성자가 아닙니다. Math의 모든 속성과 메서드는 정적입니다. 파이 상수는 Math.PI로 참조할 수 있고, 사인 함수는 매개변수 x에 대해 Math.sin(x)와 같이 호출할 수 있습니다. 상수는 JavaScript에서 가능한 최대 실수 정밀도로 정의되어 있습니다.

속성

Math.E

오일러의 상수이며 자연로그의 밑. 약 2.718.

Math.LN2

2의 자연로그. 약 0.693.

Math.LN10
10의 자연로그. 약 2.303.
Math.LOG2E
밑이 2인 로그 E. 약 1.443.
Math.LOG10E
밑이 10인 로그 E. 약 0.434.
Math.PI
원의 둘레와 지름의 비율. 약 3.14159.
Math.SQRT1_2
½의 제곱근. 약 0.707.
Math.SQRT2
2의 제곱근. 약 1.414.

메서드

참고: 삼각 함수(sin()cos(), tan(), asin(), acos(), atan(), atan2())는 매개변수와 반환값 모두 호도법(라디안)을 사용합니다.

라디안 값을 각도 값으로 변환하려면 (Math.PI / 180)으로 나누세요. 반대로 각도 값에 곱하면 라디안 값이 됩니다.

참고: 많은 수의 Math 함수 정확도는 구현에 따라 다를 수 있습니다. 즉, 각 브라우저의 결과가 다를 수 있으며, 서로 같은 JS 엔진이라도 운영체제나 아키텍쳐에 따라서 불일치하는 값을 반환할 수 있습니다.

Math.abs(x)
숫자의 절댓값을 반환합니다.
Math.acos(x)
숫자의 아크코사인 값을 반환합니다.
Math.acosh(x) 
숫자의 쌍곡아크코사인 값을 반환합니다.
Math.asin(x)
숫자의 아크사인 값을 반환합니다.
Math.asinh(x) 
숫자의 쌍곡아크사인 값을 반환합니다.
Math.atan(x)
숫자의 아크탄젠트 값을 반환합니다.
Math.atanh(x) 
숫자의 쌍곡아크탄젠트 값을 반환합니다.
Math.atan2(y, x)
인수 몫의 아크탄젠트 값을 반환합니다.
Math.cbrt(x) 
숫자의 세제곱근을 반환합니다.
Math.ceil(x)
인수보다 크거나 같은 수 중에서 가장 작은 정수를 반환합니다.
Math.clz32(x) 
주어진 32비트 정수의 선행 0 개수를 반환합니다.
Math.cos(x)
숫자의 코사인 값을 반환합니다.
Math.cosh(x) 
숫자의 쌍곡코사인 값을 반환합니다.
Math.exp(x)
Ex 를 반환합니다. x는 인수이며 E 는 오일러 상수(2.718...) 또는 자연로그의 밑입니다.
Math.expm1(x) 
exp(x)에서 1을 뺀 값을 반환합니다.
Math.floor(x)
인수보다 작거나 같은 수 중에서 가장 큰 정수를 반환합니다.
Math.fround(x) 
인수의 가장 가까운 단일 정밀도 표현을 반환합니다.
Math.hypot([x[, y[, …]]]) 
인수의 제곱합의 제곱근을 반환합니다.
Math.imul(x, y) 
두 32비트 정수의 곱을 반환합니다.
Math.log(x)
숫자의 자연로그(loge 또는 ln) 값을 반환합니다.
Math.log1p(x) 
숫자 x에 대해 1 + x의 자연로그(loge 또는 ln) 값을 반환합니다.
Math.log10(x) 
숫자의 밑이 10인 로그를 반환합니다.
Math.log2(x) 
숫자의 밑이 2인 로그를 반환합니다.
Math.max([x[, y[, …]]])
0개 이상의 인수에서 제일 큰 수를 반환합니다.
Math.min([x[, y[, …]]])
0개 이상의 인수에서 제일 작은 수를 반환합니다.
Math.pow(x, y)
x의 y 제곱을 반환합니다.
Math.random()
0과 1 사이의 난수를 반환합니다.
Math.round(x)
숫자에서 가장 가까운 정수를 반환합니다.
Math.sign(x) 
x의 양의 수인지 음의 수인지 나타내는 부호를 반환합니다.
Math.sin(x)
숫자의 사인 값을 반환합니다.
Math.sinh(x) 
숫자의 쌍곡사인 값을 반환합니다.
Math.sqrt(x)
숫자의 제곱근을 반환합니다.
Math.tan(x)
숫자의 탄젠트 값을 반환합니다.
Math.tanh(x) 
숫자의 쌍곡탄젠트 값을 반환합니다.
Math.toSource()
문자열 "Math"를 반환합니다.
Math.trunc(x) 
숫자의 정수 부분을 반환합니다.

명세

Specification
ECMAScript (ECMA-262)
The definition of 'Math' in that specification.

브라우저 호환성

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
EChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
LN2Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
LN10Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
LOG2EChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
LOG10EChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
PIChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
SQRT1_2Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
SQRT2Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
absChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
acosChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
acoshChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
asinChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
asinhChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
atanChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
atan2Chrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 4Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
atanhChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
cbrtChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
ceilChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
clz32Chrome Full support 38Edge Full support 12Firefox Full support 31IE No support NoOpera Full support 25Safari Full support 7WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 31Opera Android Full support 25Safari iOS Full support 7Samsung Internet Android Full support 3.0nodejs Full support 0.12
cosChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
coshChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
expChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
expm1Chrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
floorChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
froundChrome Full support 38Edge Full support 12Firefox Full support 26IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 26Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
hypotChrome Full support 38Edge Full support 12Firefox Full support 27IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 27Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
imulChrome Full support 28Edge Full support 12Firefox Full support 20IE No support NoOpera Full support 16Safari Full support 7WebView Android Full support ≤37Chrome Android Full support 28Firefox Android Full support 20Opera Android Full support 15Safari iOS Full support 7Samsung Internet Android Full support 1.5nodejs Full support 0.12
logChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
log1pChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
log2Chrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
log10Chrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
maxChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
minChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
powChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
randomChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
roundChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
signChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 9WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 9Samsung Internet Android Full support 3.0nodejs Full support 0.12
sinChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
sinhChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
sqrtChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
tanChrome Full support 1Edge Full support 12Firefox Full support 1IE Full support 3Opera Full support 3Safari Full support 1WebView Android Full support 1Chrome Android Full support 18Firefox Android Full support 4Opera Android Full support 10.1Safari iOS Full support 1Samsung Internet Android Full support 1.0nodejs Full support 0.1.100
tanhChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12
truncChrome Full support 38Edge Full support 12Firefox Full support 25IE No support NoOpera Full support 25Safari Full support 8WebView Android Full support 38Chrome Android Full support 38Firefox Android Full support 25Opera Android Full support 25Safari iOS Full support 8Samsung Internet Android Full support 3.0nodejs Full support 0.12

Legend

Full support  
Full support
No support  
No support

같이 보기