Answer the question
In order to leave comments, you need to log in
Is it possible through a listener to add parameters to a function?
Hello everyone) Here I wondered if we have an addEventListener listener, we pass an event and a function name in it. So now you can't add parameters to this function? Here is a code example:
function item() {
какой-то код
}
addEventListener('input', item);
addEventListener('input', item(параметр)
:?
Answer the question
In order to leave comments, you need to log in
function itemFactory(param1, param) {
return function item(event) {
// param1 and param2 are available here
}
}
document.addEventListener('input', itemFactory(true, 50));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question