When adding the eventlistener ("click", myFunction) how can I pass in a parameter to myFunction without invoking it? Like... ("click", myFunction(arrayOne)). The button is triggering a function that uses arrays. I want the function to use a specific array based on a specific button.
var btnOne = document.getElementById("btnOne);
btnOne.addEventListener("click", myFunction);
try this:
var btnOne = document.getElementById("btnOne);
btnOne.addEventListener("click", () => myFunction(params));
You can use arrow function to do it. It'll help you by not creating a new lexical scope, so no need to worry about mishandling this.
var btnOne = document.getElementById("btnOne");
btnOne.addEventListener("click", () => { myFunction(arg1, arg2...) });