Q36: What are Web Workers and how do they communicate with the main thread?

Web Workers allow running background JavaScript scripts in parallel threads separate from the main execution thread. Communication occurs via message passing using worker.postMessage() and onmessage event handlers.

Key Takeaways
  • Runs heavy scripts in isolated background threads without UI thread blocking.
  • Workers lack direct access to DOM objects (document, window).
Knowledge Check

Can a standard Dedicated Web Worker directly manipulate DOM nodes using document.getElementById?