An interesting uglify problem - declaring variables in for loop


Hi all, so I am using this tutorial to uglify my code

Everything works fine, no jshint errors, but I came across an interesting error in the minified code.

My non minified code was doing this:

for (var  i = 0; i < $scope.monitors.length; i++) {

When run through uglify, this produced

{for(var o,t=0;t<n.monitors.length;t++)

And this would cause an exception about monitors[t].Monitor being undefined (code inside the loop)

I fixed it by doing:

var i;
        for ( i = 0; i < $scope.monitors.length; i++) {`

the generated uglify code then became

{var o,t;for(t=0;t<n.monitors.length;t++)

And this solved the error

Is there is a problem in defining variables within the for loop?