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

186
Vistas
How to add messages to the callback queue?

JS is a single threaded that can run only sync code. But there methods that are async by default, like setTimeout and running actions against the DB, or HTTP requests.

Those methods are added messages to the callback queue and by the time that the call stack is empty, the methods in those messages are applied to the call stack as well to be implemented.

But, how can I add a message to the callback queue by myself?

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

0

In the browser environment, there are a couple of ways:

  1. setTimeout with a 0 interval (or similar), which queues a task
  2. queueMicrotask (relatively new, but easily polyfilled if the environment supports promises), which (you may have guessed!) queues a microtask

Node.js also has those, and a couple more that are more specific to its execution loop, like setImmediate (not expected to be standardized on browsers).

about 4 years ago · Juan Pablo Isaza Denunciar

0

This article explains it very well:

https://dev.to/bipinrajbhar/how-javascript-works-web-apis-callback-queue-and-event-loop-2p3e

The setTimeout, setImmediate, http request, dom events ...etc are all part of the Web API that is implemented in the browser and also extended in Node.JS (setImmediate for example). They are here to add async to JS functionality. Therefore, manually adding new messages to the callback queue is possible only via the Web API.

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