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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.