Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda