--- title: 나머지 연산자 (%) slug: Web/JavaScript/Reference/Operators/Remainder translation_of: Web/JavaScript/Reference/Operators/Remainder ---
{{jsSidebar("Operators")}}

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

{{EmbedInteractiveExample("pages/js/expressions-remainder.html")}}

문법

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
{{SpecName('ESDraft', '#sec-multiplicative-operators', 'Remainder operator')}}

Browser compatibility

{{Compat("javascript.operators.remainder")}}

See also