workers run in another global context that is different from the current
window. Thus, using the
windowshortcut to get the current global scope (instead of
self) within a
Worker will return an error.
The worker context is represented by a
DedicatedWorkerGlobalScope object in the case of dedicated workers (standard workers that are utilized by a single script; shared workers use
SharedWorkerGlobalScope). A dedicated worker is only accessible from the script that first spawned it, whereas shared workers can be accessed from multiple scripts.