DedicatedWorkerGlobalScope: name property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.
Note: This feature is only available inDedicated Web Workers.
Thename read-only property of theDedicatedWorkerGlobalScope interface returns the name that theWorker was (optionally) given when it was created. This is the name thattheWorker() constructor can pass to get a reference totheDedicatedWorkerGlobalScope.
In this article
Value
A string.
Examples
If a worker is created using a constructor with aname option:
js
const myWorker = new Worker("worker.js", { name: "myWorker" });theDedicatedWorkerGlobalScope will now have a name of "myWorker",returnable by running
js
self.name;from inside the worker.
Specifications
| Specification |
|---|
| HTML> # dom-dedicatedworkerglobalscope-name-dev> |