나머지 연산자 (%)

번역이 완료되지 않았습니다. Please help translate this article from English

나머지 연산자(%)는 피제수가 제수에 의해 나누어진 후, 그 나머지를 반환합니다. 항상 피제수의 부호를 따릅니다.

문법

Operator: var1 % var2

예시

(+)피제수의 나머지

 12 % 5  //  2
 1 % -2 //  1
 1 % 2  //  1
 2 % 3  //  2
5.5 % 2 // 1.5

(-)피제수의 나머지

-12 % 5 // -2
-1 % 2  // -1
-4 % 2  // -0

NaN의 나머지

NaN % 2 // NaN

Specifications

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Remainder (%)Chrome 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

Legend

Full support  
Full support

See also