[Solved] JavaScript get event with closure function?


Why not directly access e inside the function

<script>
    a[i].addEventListener("keydown",(function(){
        var index=i;
        return function(e){
            if (e.keyCode == 13 && !e.shiftKey){
                console.log(this);
                console.log(e);
                console.log(index);
            }
        };
    })(), false);

Working

16

solved JavaScript get event with closure function?