How do I pass the value (not the reference) of a JS variable to a function? [duplicate]
In modern browsers, you can use the let or const keywords to create a block-scoped variable: for (let i = 0; i < results.length; i++) { let marker = results[i]; google.maps.event.addListener(marker, ‘click’, () => change_selection(i)); } In older browsers, you need to create a separate scope that saves the variable in its current state by … Read more