SolarWind - 10 months ago 44

Javascript Question

What is the % operator in javascript?

Answer

`%`

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 operand. It always takes the sign of the dividend, not the divisor. It uses a built-in modulo function to produce the result, which is the integer remainder of dividing

`var1`

by`var2`

— for example —var1 modulo var2.There is a proposal to get an actual modulo operator in a future version of ECMAScript,

the difference being that the modulo operator result would take the sign of the divisor, not the dividend.