The += operator is a compound assignment operator used for addition. It adds the value of the right operand to the value of the left operand and assigns the result to the left operand.
Syntax:
a += b
Example: Here, x += 3 is equivalent to x = x + 3 . It adds 3 to the current value of x (which is 5 ), and assigns the result (8 ) back to x . Finally, console.log(x) prints the updated value of x , which is 8 .
Javascript
let x = 5;
x += 3;
console.log(x);
|
|