It's the remainder operator and is used to get the remainder after integer division. Lots of languages have it. For example:
10 % 3 // = 1 ; because 3 * 3 gets you 9, and 10 - 9 is 1.
Apparently it is not the same as the modulo operator entirely.
Answer from MarioDS on Stack OverflowW3Schools
w3schools.com โบ js โบ js_arithmetic.asp
JavaScript Arithmetic
The modulus operator (%) returns the division remainder. let x = 5; let y = 2; let z = x % y; Try it Yourself ยป ยท In arithmetic, the division of two integers produces a quotient and a remainder.
char - How can I use modulo operator (%) in JavaScript? - Stack Overflow
How can I use modulo operator (%) in calculation of numbers for JavaScript projects? More on stackoverflow.com
Understanding the JavaScript Modulo Operator
A quick peek at the documentation would reveal that % in JavaScript is not modulo, it's the remainder operator (or can be found in the ECMAScript specification ). This is confusing to many people, and unfortunately articles like these don't help by using the wrong terminology. The difference occurs when one of the values is negative. -21 % 4 The result of this is 3 for "mod" and -1 for "rem". This can be confusing behavior, if for example, to implement an isOdd function, you might think of something like this: function isOdd(n) { return n % 2 === 1 } However, this is wrong! It returns false for an input of -1. More on reddit.com
Understanding the JavaScript Modulo Operator
I hope you like the summary below: The post explains the Modulo operator (%) in JavaScript, which is often misunderstood and appears to produce random values. The author clarifies its function by redefining how we think about division, emphasizing that it's about dividing a number into equally-sized groups without fractional remainders. The remainder is what the modulo operator calculates. A practical use case provided is in creating circular arrays, like cycling through a list of colors indefinitely with time. This is achieved by using the modulo operator to cycle through array indices, demonstrating its utility in everyday coding. If you don't like the summary, just downvote and I'll try to delete the comment eventually ๐ More on reddit.com
Understanding the JavaScript Modulo Operator
Here's an AI-generated TL;DR to help you with the decision to read the post or not: The post explains the Modulo operator (%) in JavaScript, which is often misunderstood and appears to produce random values. The author clarifies its function by redefining how we think about division, emphasizing that it's about dividing a number into equally-sized groups without fractional remainders. The remainder is what the modulo operator calculates. A practical use case provided is in creating circular arrays, like cycling through a list of colors indefinitely with time. This is achieved by using the modulo operator to cycle through array indices, demonstrating its utility in everyday coding. Reply to this comment with feedback on how the summary can be improved. Downvote to delete this comment. More on reddit.com
Videos
01:00
Master the Modulo Operator in JavaScript with Real-World Examples ...
JavaScript Basics - Modulus
02:23
You'll Use This More Than You Think... JavaScript Modulo Operator ...
04:45
Javascript Modulo Operator Explained | Understanding modulo rest ...
04:40
Use Cases for Remainders in Programming (with JavaScript) - YouTube
03:16
What is MODULO? | JavaScript in LESS-THAN 3 | JavaScript Beginner ...
MDN Web Docs
developer.mozilla.org โบ en-US โบ docs โบ Web โบ JavaScript โบ Reference โบ Operators โบ Remainder
Remainder (%) - JavaScript - MDN Web Docs
For two values of the same sign, ... which can make them differ by one unit of d. To obtain a modulo in JavaScript, in place of n % d, use ((n % d) + d) % d....
Mimo
mimo.org โบ glossary โบ javascript โบ modulo-operator
JavaScript Modulo Operator: Syntax, Usage, and Examples
Learn how JavaScript's modulo operator works with positive and negative numbers, floating points, and loops. Includes syntax, tips, and real examples.
Mastering JS
masteringjs.io โบ tutorials โบ fundamentals โบ modulus
The Modulus Operator in JavaScript - Mastering JS
The modulus operator in JavaScript returns the remainder when the first operand is divided by the second operand. Here's what you need to know.
Educative
educative.io โบ answers โบ what-is-the-modulo-operator-in-javascript
What is the modulo operator in JavaScript?
The modulo operator is represented by the % character in JavaScript.
W3Schools
w3schools.com โบ js โบ tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
Delft Stack
delftstack.com โบ home โบ howto โบ javascript โบ javascript modulo
Modulo Operator(%) in JavaScript | Delft Stack
March 11, 2025 - Learn how to use the modulo operator (%) in JavaScript with this comprehensive tutorial. Explore its applications, check for even or odd numbers, and discover practical examples to enhance your coding skills. Ideal for beginners and experienced developers looking to master this essential operator.
TutorialsPoint
tutorialspoint.com โบ What-is-Modulus-Operator-in-JavaScript
What is Modulus Operator (%) in JavaScript?
November 25, 2022 - In the expression a % b, a is called dividend, while b is known as divisor. In case of the modulo, the expression ((a % b) + b) % b is used to find out the remainder, where the sign of the resultant remainder will be similar to the sign of the divisor, b in this case.
W3Schools
w3schools.com โบ js โบ tryit.asp
W3Schools Tryit Editor - JavaScript Arithmetic
The W3Schools online code editor allows you to edit code and view the result in your browser