Avoid embedded for loops
I'm happy to use EcmaScript 6 features


Try array comprehensions!

var vals = range(0, 3);
return [ [i, j, k, l] for (i of vals) for (j of vals) for (k of vals) for (l of vals) ]


Still, it translates to the same nested loops. If you need a variable nesting level, you  can use a recursive solution.