Worker.terminate()

The terminate() method of the Worker interface immediately terminates the Worker. This does not offer the worker an opportunity to finish its operations; it is stopped at once.

Syntax

myWorker.terminate();

Parameters

None.

Returns

Void.

Example

The following code snippet shows creation of a Worker object using the Worker() constructor, which is then immediately terminated.

var myWorker = new Worker('worker.js');

myWorker.terminate();

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'Worker.terminate()' in that specification.
Living Standard

Browser compatibility

BCD tables only load in the browser

See also

The Worker interface it belongs to.