How can I keep the variables in the event listener to avoid being overwritten?
Below is an example. It will alert twice of 'second', instead of 'first' then 'second'

```
var firstVar = 'first';

window.addEventListener('load',function(){
    alert(firstVar);
});

var firstVar = 'second';

window.addEventListener('load',function(){
    alert(firstVar);
});

```

I have tried, as below too.

```
var firstVar = 'first';

window.addEventListener('load',function(){
    var temp = firstVar;
    alert(temp);
});

var firstVar = 'second';

window.addEventListener('load',function(){
    var temp = firstVar;
    alert(temp);
});

```

I event tried to use bind(this) but none of them is working.
Is there a way for this to work or there's no way it will works?

Thanks