Can anybody explain to me how this casue an infinite loop? I got this from an example of a javascript book.
The code is as follows:
function foo() {
function bar(a) {
i = 3; // changing the `i` in the enclosing scope's for-loop
console.log( a + i );
}
for (var i=0; i<10; i++) {
bar( i * 2 ); // oops, inifinite loop ahead!
}
}
foo();
ivariable so you never reach the terminal conditioni<10. Which part of this is unclear?