Javascript Reference
Categories: Operators

javascript Operators %

@March 15, 2008, 1:22 a.m.
% Firefox/Netscape/NN 2 IE 3 ECMA 1  

  

The modulus operator divides the number to the left of the operator by the number to the right. If a remainder exists after the division, the expression evaluates to that remainder as an integer. If there is no remainder, the returned value is zero. Both operands must be numbers. An expression with this operator evaluates to a number. Even if you aren't interested in the remainder value, this operator is a quick way to find out if two values are evenly divisible.

 
Example
 
if ((dayCount % 7) > 0) {
    ...
}

Powered by Linode.