JavaScript arithmetic modulus operator is used to return the remainder of the operands. Here also the left operator is the dividend and the right operator is the divisor.
Syntax:
a%b
Return Type: Remainder of the operands.
Example 1: In this example, we will check the remainder with Number and Infinity.
Javascript
console.log(100%23); console.log(Infinity%20); |
Output:
8 NaN
Example 2: In this example, we will use the modulus operator on the negative number and NaN
Javascript
console.log(-100%23); console.log(NaN%20); |
Output:
-8 NaN
Supported Browsers:
- Chrome
- Edge
- Firefox
- Opera
- Safari
We have a complete list of Javascript Arithmetic operators, to check those please go through this JavaScript Arithmetic Operators article.