Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

216
Vistas
Meaning of testing 'addEventListener' in htmlElement

What is the purpose of testing the following condition?

if ('addEventListener' in htmlElement) {
  // do sth
}

I have seen that in some code examples of event emitter constructors. I first thought it was to test whether an event was bound to a HTML element but it turns out the condition also returns true for HTML elements with no events attached to them.

Edit:

Here's a real life example to give a bit more context.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This code checks whether the addEventListener property is available. The method addEventListener is a part of EventTarget interface. All DOM elements should have it, I think.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda