Modulus(%) Arithmetic Operator in JavaScript

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.
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!



