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

# environment

[JS](..) ⟩ [concepts](../../browser/concepts) ⟩ environment

{% hint style="success" %}
JavaScript code can be run：

* in [browser](../../browser "mention") (**client** code)
* in [worker](../../browser/api/worker "mention")
* in [node.js](env/node.js "mention") (**server** code)
{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}
* <mark style="color:yellow;">**environments**</mark>
  * [browser](../../browser "mention") (client code)
  * [node.js](env/node.js "mention") (server code)
  * [worker](../../browser/api/worker "mention")
  * [js-engine](env/js-engine "mention")
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="warning" %}
[object](../scope/global/object "mention") in each <mark style="color:purple;">**environment**</mark>：

* [browser](../../browser "mention")： [window](../scope/global/object/window "mention") (a [`Window`](https://developer.mozilla.org/en-US/docs/Web/API/Window) object)
* [worker](../../browser/api/worker "mention")： [self](../../browser/api/worker/self "mention") (a [`WorkerGlobalScope`](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope) object)
* [node.js](env/node.js "mention")： [global](../scope/global/object/global "mention") (an object called [`global`](https://nodejs.org/api/globals.html#globals_global))
{% endhint %}

{% hint style="info" %}
every <mark style="color:purple;">**environment**</mark> exposes some of its own <mark style="color:yellow;">**built-ins**</mark> into the [global](../scope/global "mention")：

* [browser](../../browser "mention")：<mark style="color:blue;">**`console`**</mark>, [dom](../../browser/dom "mention")(including [window](../scope/global/object/window "mention")), <mark style="color:yellow;">**timers**</mark>, [api](../../browser/api "mention")
* [worker](../../browser/api/worker "mention")：??? (anything else?)
* [node.js](env/node.js "mention")：???
{% endhint %}
{% 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") ⟩ Chapter 4: [Around the Global Scope](https://github.com/getify/You-Dont-Know-JS/blob/2nd-ed/scope-closures/ch4.md#chapter-4-around-the-global-scope)
{% endtab %}

{% tab title="📘 手冊" %}
* [Global object](https://developer.mozilla.org/en-US/docs/Glossary/Global_object)
{% endtab %}

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