JavaScript · Senior · Question 12 of 75
What doesn't code inside a Web Worker have?
- ✓Correct answer: Access to the DOM; it talks to the main thread via
postMessage - 2Access to
fetchand timers - only computations are allowed - 3The ability to import modules - a worker is always one file
Explanation
A worker runs in a separate thread, so heavy computations don't block the UI. fetch, timers, IndexedDB and modules (type: 'module') are available. Data is passed by copying (structured clone) or by transferring ownership (Transferable, e.g. ArrayBuffer).