Migrated from: aprilmintacpineda/inferno-fluxible#1 (comment)
https://github.com/aprilmintacpineda/inferno-fluxible/blob/master/src/index.js#L38
Consider the following:
let a = [1, 2, , 3, 4];
for (b = 0; b < a.length; b++) {
if (a.length > 100) {
console.log('demo succeeded');
break;
}
console.log(a[b]);
a.push('_' + b);
}
In the code above, variable a
's elements increases in length, therefore, the for loop
more than expected.
The code below fixes it:
let a = [1, 2, , 3, 4];
const limit = a.length;
console.log('limit:', limit);
for (b = 0; b < limit; b++) {
if (a.length > 100) {
console.log('demo succeeded');
break;
}
console.log(b, ':', a[b]);
a.push('_' + b);
}
console.log('done');