![]() |
VOOZH | about |
The modulus (%) arithmetic operator in JavaScript returns the remainder after dividing one number by another. It is used for tasks like determining even or odd numbers, cycling through values within a range, and managing periodic events in programming.
Syntax:
a%bReturn Type: Remainder of the operands.
Example 1: We will check the remainder with Number and Infinity in this example.
Output:
8
NaN
Example 2: In this example, we will use the modulus operator on the negative number and NaN