JavaScript removeEventlistener callback with argument

Currently I'm trying to do like this:

el.addEventListener('scroll', callFunc);

el.removeEventListener('scroll', callFunc);

But with callback function which has parameters

el.addEventListener('scroll', () => callFunc(pr1, pr2));

el.removeEventListener('scroll', () => callFunc(pr1, pr2));

Is it possible to remove eventListener callback funcion with parameters?

Submitted June 05th 2021 by Admin


  1. Create function with bounded arguments:
const func = callFunc.bind(null, pr1, pr2);
  1. Pass created function to addEventListener and removeEventListener.

Admin | 3 months ago

Relevant Questions

Deleting a todo - MERN Stack

September 10th 2021