I can not understand the result provided by an array of functions in javascript
var myArray = [];
for (var i=0;i<5;i++){
myArray.push(function(a){
return i+a;
})
}
alert(myArray[0](2));
alert(myArray[1](2));
I get 7 as a result for both, as if the value of i for each function in the array was 5. Could you help me to understand this ?