Remainder Assignment(%=) Operator in Javascript
Last Updated :
16 Mar, 2023
The Remainder Assignment Operator in javascript is represented by “%=”. This operator is used to divide the value of the variable by another operand and assign the remainder to the variable which is the first operand. This can be also explained as assigning the remainder to the first operand which is obtained by dividing the variable from the second operand.
Syntax:
x %= y
or
x = x % y
Example 1: In this example, we will use the remainder operator.
Javascript
let a = 17;
console.log(a %= 2);
console.log(a %= 0);
console.log(a %= 'bar' );
|
Example 2: In this example, we will going to see the use of the remainder operator.
Javascript
let a = 28;
a %= 7;
console.log(a);
let b = NaN;
b %= 2;
console.log(b);
|
We have a complete list of Javascript Assignment Operators, Please check this article Javascript Assignment Operator.
Supported Browser:
- Chrome 1
- Edge 12
- Firefox 1
- Opera 3
- Safari 1
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...