JavaScript Code

Modulus Operator in JavaScript

Modulus Operator

In JavaScript, arithmetic Modulus operator is used to find the remainder of the division of two numeric values.


% symbol is used for arithmetic modulus operator

arithmetic modulus operator takes two values/variables as operands and returns the remainder in the division of the left operand divided by the right operand

a % b  //remainder when a divided by b
6 % 4  //remainder when 6 divided by 4


  1. Find the remainder when value in a is divided by b.
var a = 6;
var b = 4;

var remainder = a % b;