Favorites

JavaScript % Remainder Operator

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
%
JavaScript Arithmetic OperatorThis operator is supported by all modern browsers.
Updated 28th November 2026

The remainder operator (%) returns what is left over after dividing one number by another. It's often used to check for even numbers or to wrap values around.

Description

The remainder operator % returns the remainder left over when the left operand is divided by the right. The result has the sign of the left operand, so -7 % 3 is -1; it's a remainder, not a true modulo. To wrap negative values into a range, use ((n % m) + m) % m.

Common uses are checking for even or odd numbers (n % 2 === 0), doing something every nth time, and cycling through items.

For floating point operands, the remainder can be a decimal: 5.5 % 2 is 1.5. Taking a remainder by zero gives NaN, and with BigInts it throws a RangeError. The remainder operator has the same precedence as multiplication and division.

Properties

Operator
%
Category
Arithmetic
Precedence
12 (1 is lowest, 18 is highest)
Associativity
left-to-right

Syntax

x % y

Example

console.log(10 % 3);
console.log(-7 % 3);
console.log(((-7 % 3) + 3) % 3);
for (let i = 1; i <= 6; i++) console.log(i, i % 2 === 0 ? 'even' : 'odd');

Browser Support

The following information will show you the current browser support for the % operator. Hover over a browser icon to see the version that first introduced support for this operator.

This operator is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee