Name

WorkerGlobalScope

Inherits from

EventTarget, Global

Synopsis

A Worker thread runs in a completely different execution environment than the parent thread that spawned it. The global object for a worker is a WorkerGlobalScope object, so this page describes the execution environment “inside” a Worker. Since WorkerGlobalScope is a global object, it inherits the Global object of core JavaScript.

Properties

In addition to the properties listed here, WorkerGlobalScope also defines all of the core JavaScript global properties, such as Math and JSON.

readonly WorkerLocation location

This property is like the window.location Location object: it allows a worker to inspect the URL it was loaded from and includes properties that return individual portions of the URL.

readonly WorkerNavigator navigator

This property is like the window.navigator Navigator object: it defines properties that allow a worker to determine what browser it is running in and whether it is currently online or not.

readonly WorkerGlobalScope self

This self-referential property refers to the WorkerGlobalScope global object itself. It is like the window property of the Window object in the main thread.

Methods

In addition to the properties listed here, WorkerGlobalScope also defines all of the core JavaScript global functions, such as isNaN() and eval().

void clearInterval(long handle)

This method is just like the Window method of the same name.

void clearTimeout(long handle)

This method is just like the Window method of the same name. ...

Get JavaScript: The Definitive Guide, 6th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.