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

327
Vistas
what is the difference events and tasks?

I am learning event loop, but I don't distinguish terminology about events and tasks.In the event loop context,I can understand "task" in MDN,

tasks are triggered by events.A task is any JavaScript code which is scheduled to be run by the standard mechanisms such as initially starting to run a program, an event callback being run, or an interval or timeout being fired.

Async Tasks are triggered by events. Can I understand that events are tasks that executed in another thread? what is event in the event loop?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Events are signals that tell the event loop that a task is now ready to run. They are not part of the event loop, they come from outside. Examples are DOM events (such as clicks, keyboard events etc), network events (readystatechange, progress), timer events (from setTimeout). Events are not tasks themselves. They may or may not be fired by another thread - often enough, the event loop polls for them.

about 4 years ago · Santiago Trujillo Denunciar

0

Events do not occur in the event loop. When an event is dispatched, the callback function that must be executed is pushed onto the macrotask queue. There is no designated place for events inside the event loop, since events are not functions themselves. (macrotask and task is the same thing)

To give you a concrete example, let's say you have a button and a user clicks that button. When the user clicks that button, the callback function that must be executed is pushed onto the macrotask queue and when the call stack is completely empty the event loop will push the callback function from the macrotask queue onto the call stack. There is also a microtask queue but I don't want to confuse you.

I suggest reading the following articles that perfectly describe the event loop in chrome and how it works:

  • https://towardsdev.com/event-loop-in-javascript-672c07618dc9
  • https://blog.insiderattack.net/javascript-event-loop-vs-node-js-event-loop-aea2b1b85f5c
  • https://www.youtube.com/watch?v=28AXSTCpsyU&ab_channel=TraversyMedia ( I don't quite agree with everything he says, but it's a good starting point. I suggest reading the articles first. )
about 4 years ago · Santiago Trujillo 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