---
description: 🚧 施工中
---

# web worker

[JS](../../js) ⟩ [browser](..) ⟩ [web API]() ⟩ web worker

{% hint style="success" %}
(a JS [env](../../js/concept/env "mention")) an <mark style="color:yellow;">**extension**</mark> on top of [..](.. "mention")-JS behavior, which allows a <mark style="color:yellow;">**JS file**</mark> to run in a completely <mark style="color:yellow;">**separate thread**</mark> from the thread that's running the main JS program.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
<mark style="color:purple;">**Web Worker**</mark> code&#x20;

* <mark style="color:red;">**does not**</mark> have <mark style="color:yellow;">**access**</mark> to the [dom](../dom "mention"). (<mark style="color:red;">**can't**</mark> access [window](../../js/scope/global/object/window "mention"), for example)
* <mark style="color:red;">**does not**</mark> <mark style="color:yellow;">**share**</mark> the [global](../../js/scope/global "mention") with the <mark style="color:yellow;">**main JS program**</mark>.
{% endhint %}

{% hint style="success" %}
<mark style="color:purple;">**Web Worker**</mark> code <mark style="color:green;">**do**</mark> have access to the following [](<> "mention")：

* naviagtor
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* <mark style="color:purple;">**web worker**</mark> is a JS [env](../../js/concept/env "mention").
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [ydkjs-scope-and-closures-v.2](../../master/ref/book/you-dont-know-js-series-v.2/ydkjs-scope-and-closures-v.2 "mention") ⟩ Ch. 4 ⟩ [Web Worker](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch4.md#web-workers)
* [ ] MakeUseOf ⟩ [An Introduction to JavaScript Web Workers](https://www.makeuseof.com/javascript-web-workers-introduction/)
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [Web APIs](https://developer.mozilla.org/en-US/docs/Web/API) ⟩ [Worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker)
{% endtab %}

{% tab title="🚧" %}
* [ ] navigator
{% endtab %}
{% endtabs %}
