I am executing the following seemingly straightforward code
var number = 0;
while (number <= 12) {
console.log(number);
number = number + 2;
}
and I am getting different results in the browser and in Node. When I run it in the Firebug(v 2.0.4 ) console on Firefox(v. 32.0.3) the result I get is
0 2 4 6 8 10 12 14
which is not`the result I expected.
In Node, the same code gives me the correct answer which is
0 2 4 6 8 10 12
Is there anything I'm missing regarding the behaviour in the browser???
Thanks in advance.
If you run a script in Firebug's console, then it will evaluate the code. So it's evaluating the value of the last number in the while loop (which is now 14) and prints that out. It's actually printing out the value of number
8 times but groups them in 1 print out.
You can see the same effect by just typing in "window" in the command line. It's evaluating it's value and prints it out in the console.
More info can be found in the description to Firebug's command line.