I have a a function that looks like this:
function strip(o) {
for (var i in o) {
var test = basic.arr.some(function(x) {return x === i} );
//JSlint -- don't make functions within loop
if (test)
delete o[i];
}
return o;
}
the code works and JSlint complains.
I understand that defining multiple functions with a loop' s repeating expression will end up in creating multiple functions each retaining the last repeating expression's value (because each loop doesn't have a distinct scope);
but in this case , since I'm evaluating the function right away, I can't think of a scenario where the actual value of i
would change;
I've already resolved using a forEach method but would like to understand why this can eventually lead to problems.