i am trying to figure out, why do i end up with different outcome, when i use a++ versus ++a in a while loop? i know that they are postfix and prefix operations but still do not get why i am getting the results i get
var a = 1;
while (a < 3) {
console.log(a);
a++;
}
i ger results: 1, 2, 2 , when using ++a instead of a++ i get different outcome.
var a = 1;
while (a < 3) {
console.log(a);
++a;
}
in this case i get 1,2,3. can someone explain operations order step by step and why do i get the output i get?