Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Modulus Operator (%) (JavaScript)

Divides the value of one expression by the value of another, and returns the remainder.

result = number1 % number2


Any variable.


Any numeric expression.


Any numeric expression.

The modulus, or remainder, operator divides number1 by number2 and returns only the remainder as result. The sign of result is the same as the sign of number1. The value of result is between 0 and the absolute value of number2.

For example, in the following expression, A (which is result) equals 5.6.

A = 19 % 6.7

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards. See Version Information.

Community Additions

© 2015 Microsoft