A loop within a function that is also in a loop gi

2019-08-30 07:21发布

问题:

How can i get this function out of the i iteration loop, since jshint gives me an error.

 for (i = 0; i < portfolios.length; i++) {
            return function () {
                for (h = 0; h < markers.length; h++) {
                    markers[h].infobox.close();
                }
                markers[i].infobox.open(map, this);
            };
        })(marker, i));
    }
}

thanks!