problem description
I want to pass a parameter of a global variable to the callback function. Although I know that it can be accessed directly without passing parameters, I want to try it, but something goes wrong. I can"t find the passed parameter in the callback function
related codes
var temp = {};
temp.index = 0;
document.getElementById("d").addEventListener("click", function (e, temp) {
console.log(temp);
move(e, temp);
}, false)
function move(e, obj) {
obj.index = 2;
}
result
question
I don"t understand why the method of passing parameters to global variables cannot be found in the callback function
.