As someone new to js, I was playing with loops when I encountered some peculiar behavior with the following code:
var i = 5;
while(i!=0){
console.log(i);
i--;
}
OUTPUT: 543211
I replicated the same code in c++ :
int i = 5;
while(i!=0){
cout<<i;
i--;
}
OUTPUT: 54321
It'd help to know if I'm missing some important differences between the two languages.