If you are a beginner in programming then += might be a little confusing to you. But you don’t need to worry, it is simple and easy to understand.
The operator is simply a short notation for adding a variable with another variable/value and then storing it in the same variable.
If you want a number to be added to another value/itself and stored in the same variable.
This is a general way of doing the addition.
let num=1; num=num+num; // print 2 as output on console console.log(num);
In the above code at line number 2, the same line can be written in a more shorthand version using += addition operator.
num+=num; // shorhand for num=num+num;
let val=5; val=val+50; // print 55 as output on console console.log(val);
val+=50; // shorhand for val=val+50;
- Node JS Post Request