Modulo (%)
Der Modulo-Operator (%) gibt den Restwert zurück, der übrig bleibt wenn ein Operand durch einen anderen geteilt wird. Das Vorzeichen ergibt sich aus der Wahl der Quotienten.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
Operator: var1 % var2
Examples
Remainder with positive dividend
12 % 5 // 2
1 % -2 // 1
1 % 2 // 1
2 % 3 // 2
5.5 % 2 // 1.5
Remainder with negative dividend
-12 % 5 // -2
-1 % 2 // -1
-4 % 2 // -0
Remainder with NaN
NaN % 2 // NaN
Specifications
Browser compatibility
BCD tables only load in the browser