Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
Remove an event listener for arrow function with parameters

In JavaScript, how can I remove an event listener that was added using an arrow function with parameters?

class myClass {

    animateIn(callback) {

        // Add an event listener for the end of the animation
        this.myDomElement.addEventListener(
            'animationend',
            (e) => this.onAnimateInAnimationEnd(e, callback)
        );
    }

    onAnimateInAnimationEnd = (e, callback) => {

         // Remove the event listener for the end of the animation
        this.myDomElement.removeEventListener(
            'animationend',
            (e) => this.onAnimateInAnimationEnd(e, callback)
        );
    }
}

I understand that using this.onAnimateInAnimationEnd instead of (e) => this.onAnimateInAnimationEnd(e, callback) will remove the event listener correctly. However, that does not allow me to access the callback parameter inside onAnimateInAnimationEnd.

How do I make it work with both e, which is related to the event I am listening to, and callback, which is not related to that event?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!