You could learn a couple of things just by looking the code of others. If you use jQuery you can see the source and find this kind of code in many places. Also:
var x = a || b || (function(){ /* stuff here */ })()
% is the modulus operator. It's the remainder when you divide...so 0 % 4 == 0, 1 % 4 == 1, 2 % 4 == 2, 3 % 4 == 3, then 4 % 4 == 0 again. It's useful in that the result cycles through 0 <= x % n < n.
https://gist.github.com/789200