My Journey to Learning Javascript: Notes- Increment / decrement operators


Math operators can be used to used to increment or decrement value.

This is used to increment by one (++) and ( — ) is used to decrement by one. These two variables are the same.


var newVariable = myVariable++;
var newVariable = myVariable+1;

var newVariable = myVariable- -;
var newVariable = myVariable-1;



You could also decide how much you would like to increment or decrement. by using (+=) or (-=) followed by a number.


var myVariable+= 10;
Var myVariable-= 10;


Order of operations also apply in javascript.