Iterate from "0" to "ZZZZZ"
Minor observations:


I'd just hardcode the charset in this case. Doing so is faster to write (and a lot more explicit) than building it with a bunch of loops.
The modulo operator % is a good friend to have for this, as it'll let you "wrap around" array indices.


Overall, there's too much code here, I think. This is just counting in base 62.

It'd be awesome if Number.prototype.toString() accepted 62 as an argument, but, unfortunately, it only seems to accept bases 2-36. Similarly, it'd be great if we could somehow use the built-in base64 encoding function (btoa), but it's, well, base 64 (and it's got other issues). So we do have to roll our own.

Now, if this was base 10, we could obviously just do

var limit = Math.pow(10, 5); // i.e. 100000

for(var i = 0 ; i &lt; limit ; i++) {
  console.log(i);
}


which will print 0-99999.

Using this same basic setup, we can print our base62 values. Our limit will be \$base^{numberOfDigits}\$ just like \$10^5\$ will end up printing five 9s. So for 0-ZZZZZ we'll need to loop from zero to Math.pow(62, 5).

And of course, we'll have to do the actual base62 conversion. The basic algorithm is:


Get the char corresponding to \$value\bmod base\$ (e.g. charset[538 % 62] =&gt; charset[42]) and add it to the output string.
Set \$value\$ to the quotient of \$\frac{value}{base}\$ (e.g. Math.floor(538 / 62) =&gt; 8).
If value is bigger than zero, go to step 1. Otherwise, return the output.


In code:

var output = "";
do {
  output = charset[value % base] + output;
  value = (value / base) | 0; // bitwise floor trick
} while(value &gt; 0);
return output;


Putting it all together, I get this:

// define our base62 function (using an IIFE)
var toBase62 = (function () {
  var charset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
      base = charset.length; // 62, natch

  return function (value) {
    // TODO: It'd be nice to guard against negative values here (see comments)
    var string = "";
    do {
      string = charset[value % base] + string;
      value = (value / base) | 0;
    } while(value &gt; 0);
    return string;
  }
}());

// loop for a long, long time
for(var i = 0, l = Math.pow(62, 5) ; i &lt; l ; i++) {
  console.log( toBase62(i) );
}


Note that it takes forever to print all the 916,132,832 values from 0 up to \$62^5\$. JS ain't that fast. I haven't explored optimization, so for testing, I'd advice using (much) fewer iterations.