files/en-us/web/api/workerglobalscope/index.md
{{APIRef("Web Workers API")}}{{AvailableInWorkers("worker")}}
The WorkerGlobalScope interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by {{domxref("Window")}} objects — in this case event handlers, the console or the associated {{domxref("WorkerNavigator")}} object. Each WorkerGlobalScope has its own event loop.
This interface is usually specialized by each worker type: {{domxref("DedicatedWorkerGlobalScope")}} for dedicated workers, {{domxref("SharedWorkerGlobalScope")}} for shared workers, and {{domxref("ServiceWorkerGlobalScope")}} for ServiceWorker. The self property returns the specialized scope for each context.
{{InheritanceDiagram}}
This interface inherits properties from the {{domxref("EventTarget")}} interface.
true) or not (false).Performance interface are available to workers.WorkerGlobalScope itself. Most of the time it is a specific scope like {{domxref("DedicatedWorkerGlobalScope")}}, {{domxref("SharedWorkerGlobalScope")}} or {{domxref("ServiceWorkerGlobalScope")}}.This interface inherits methods from the {{domxref("EventTarget")}} interface.
importScripts('foo.js', 'bar.js');.navigator.onLine switched to false.navigator.onLine switched to true.You won't access WorkerGlobalScope directly in your code; however, its properties and methods are inherited by more specific global scopes such as {{domxref("DedicatedWorkerGlobalScope")}} and {{domxref("SharedWorkerGlobalScope")}}. For example, you could import another script into the worker and print out the contents of the worker scope's navigator object using the following two lines:
importScripts("foo.js");
console.log(navigator);
[!NOTE] Since the global scope of the worker script is effectively the global scope of the worker you are running ({{domxref("DedicatedWorkerGlobalScope")}} or whatever) and all worker global scopes inherit methods, properties, etc. from
WorkerGlobalScope, you can run lines such as those above without specifying a parent object.
{{Specifications}}
{{Compat}}