Defining functions inside of loops can lead to bugs such as this one:

var funs = [];
for (var i = 0; i < 13; i++) {
  funs[i] = function() { // Non-Complian
    return i;
  };
}
print(funs[0]()); // 13 instead of 0
print(funs[1]()); // 13 instead of 1
print(funs[2]()); // 13 instead of 2
print(funs[3]()); // 13 instead of 3
...