If I do a simple loop with a while, it is evaluating my ++
operator after the first loop, does this mean that my while operator makes a small scope saving my i
and after it finishes evaluating it applies the ++
operator on it? Why does this happen with this operator and also happens on the --
but not with lets say a simple sum i + 1
?
var i = 0;
while(i++ < 1) { console.log(i) }
My output is
1
var i = 1;
while(i-- > 1) { console.log(i) }
My output is
0
var i = 0;
while(i + 1 < 1) { console.log(i) }
My output is
undefined