MDN Web Docs

Value

A MessagePort object.

Examples

The following code snippet shows creation of a SharedWorker object using the SharedWorker() constructor. Multiple scripts can then access the worker through a MessagePort object accessed using the SharedWorker.port property — the port is started using its start() method:

js

const myWorker = new SharedWorker("worker.js");
myWorker.port.start();

For a full example, see our Basic shared worker example (run shared worker.)

Specifications

Specification
HTML
# dom-sharedworker-port-dev

Browser compatibility

See also

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗