function foo(count) { var ret = [] for (var i=0; i < count; i++) { ret [i] = function i() { return this.indexOf(i) } } return ret; }
var count = 1000000; var arr = foo(count); for (var i = 0; i < count; i++) arr[i]();