title: Variable amount of nested for loops
body: <p><strong>Edit: I'm sorry, but I forgot to mention that I'll need the values of the counter variables. So making one loop isn't a solution I'm afraid.</strong></p>
  
  <p>I'm not sure if this is possible at all, but I would like to do the following.
  To a function, an array of numbers is passed. Each number is the upper limit of a for loop, for example, if the array is <code>[2, 3, 5]</code>, the following code should be executed:</p>
  
  <pre><code>for(var a = 0; a &lt; 2; a++) {
       for(var b = 0; b &lt; 3; b++) {
            for(var c = 0; c &lt; 5; c++) {
                  doSomething([a, b, c]);
            }
       }
  }
  </code></pre>
  
  <p>So the amount of nested for loops is equal to the length of the array. Would there be any way to make this work? I was thinking of creating a piece of code which adds each for loop to a string, and then evaluates it through <code>eval</code>. I've read however that <code>eval</code> should not be one's first choice as it can have dangerous results too.</p>
  
  <p>What technique might be appropriate here?</p>