Javascript variable scope inside for loop
<p>How do I maintain access to the <code>i</code> variable inside my for loop below? I'm trying to learn, not just get the answer, so a bit of explanation would be very helpful. Thank you!</p>

<pre><code>var el, 
    len = statesPolyStrings.length;

for (var i = 0; i &lt; len; i++) {
    el = document.getElementById(statesPolyStrings[i]);

    google.maps.event.addDomListener(el, 'mouseover', function() {
        $("#"+statesPolyStrings[i]).addClass("highlight");
        statesPolyObjects[i].setOptions({ strokeWeight: '2' });
    });
}
</code></pre>
