fourth solution would be naming the function with the iterator (as in my example below) and calling indexOf(iterator) when the function is invoked
function foo(count) {
var ret = []
for (var i=0; i < count; i++) {
ret [i] = function i() { return this.indexOf(i) }
}
return ret;
}