Remainder (%) Operator in JavaScript

Last Updated : 14 Jul, 2026

The remainder (%) operator returns the remainder left after dividing one number by another. It is commonly used in arithmetic calculations and conditional logic.

  • Returns the remainder after dividing one number by another.
  • Commonly used to check even/odd numbers and cycle through values.
  • Returns NaN for invalid operations, and the result has the same sign as the dividend (left operand).

Syntax:

a%b

Return Type: number (the remainder of the division, or NaN for invalid operations)

Example 1: Positive Numbers and Infinity

JavaScript
console.log(100%23);
console.log(Infinity%20);

Output
8
NaN

Example 2: Negative Numbers and NaN

JavaScript
console.log(-100%23);
console.log(NaN%20);

Output
-8
NaN
Comment