January 2020
Intermediate to advanced
548 pages
13h 36m
English
The remainder operator (%), also known as the modulo operator, is similar to the division operator. It accepts two operands: a dividend, on the left side, and a divisor on the right side. It will return the remainder following an implied division operation:
10 % 5; // => 010 % 4; // => 210 % 3; // => 110 % 2; // => 0
If the divisor is zero, the dividend is Infinity, or either operand is NaN, then the operation will evaluate to NaN:
Infinity % Infinity; // => NaNInfinity % 2; // => NaNNaN % 1; // => NaN1000 % 0; // => NaN
And if the divisor is Infinity, then the result will be equal to the dividend:
1000 % Infinity; // => 10000.03 % Infinity; // => 0.03
The modulo operator is useful in situations where you wish to know ...
Read now
Unlock full access