What is the % operator in JavaScript? [duplicate]
问题 This question already has answers here : What does % do in JavaScript? (9 answers) Closed 3 years ago . I am trying to decipher a piece of JS code (while (obviously) my JS knowledge is null). What is the % operator in the code below? m[p1%2][q1] = 0.0; for(j=q1+1; j <= q2; j++) m[p1%2][j] = m[p1%2][j-1] + 1; 回答1: % is remainder operator. It gives the remainder after division. Quoting from MDN The remainder operator returns the remainder left over when one operand is divided by a second