> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/grammar/statement/expr/primary.md).

# primary expression

the simplest expressions. (literal, keyword, variable, global object property)

[JS](/web/js.md) ⟩ [statement](/web/js/grammar/statement.md) ⟩ [expression](/web/js/grammar/statement/expr.md) ⟩ primary

{% hint style="success" %}
an [expression](/web/js/grammar/statement/expr.md) that <mark style="color:red;">**doesn't**</mark>**&#x20;**<mark style="color:yellow;">**include**</mark>**&#x20;**<mark style="color:red;">**any simpler**</mark>**&#x20;**<mark style="color:yellow;">**expressions**</mark>, they are：

* [literal](/web/js/grammar/token/literal.md) (~~<mark style="color:red;">object/array literal not included</mark>~~, MDN includes these!)
* [keyword](/web/js/grammar/token/keyword.md) (some of them, not all)
* [RHS reference](/web/js/variable/access/rhs.md) to [variable](/web/js/variable.md) / [global object property](/web/js/scope/global/object/prop.md)

```javascript
// examples
123          // ⭐️ literal
null         // ⭐️ keyword (reference)
name         // ⭐️ variable (reference)
undefined    // ❗️ global object property (reference)
```

{% endhint %}

{% tabs %}
{% tab title="🔴 主題" %}

* <mark style="color:yellow;">**primiary expressions (listed in**</mark> [**MDN**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators#primary_expressions)<mark style="color:yellow;">**)**</mark>
  * [this](/web/js/concept/execution-context/this.md) -  property of [execution context](/web/js/concept/execution-context.md) ([environment record](/web/js/concept/execution-context/lexical-environment/environment-record.md), actually).
  * [function](/web/js/val/func.md) - defines a [function expression](/web/js/val/func/expr.md).
  * [class](/web/js/val/class.md) -  defines a class expression.
  * [`function*`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function*) defines a generator function expression.
  * [`yield`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield)  pause and resume a generator function.
  * [`yield*`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield*) delegate to another generator function or iterable object.
  * [`async function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function) defines an async function expression.
  * [await](/web/js/async/await.md) - wait for the promise's future value.
  * [`async function*`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/async_function*) define an async generator function expression.
  * [array literal](/web/js/val/builtin/arr/create/arr.md) - [`[]`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&#x20;
  * [object literal](/web/js/val/obj/create/obj.md) - [`{}`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer)&#x20;
  * [`/ab+c/i`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) regular expression literal syntax.
  * [`( )`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping) grouping operator.
    {% endtab %}

{% tab title="👥 相關" %}

* [literal](/web/js/grammar/token/literal.md) / [keyword](/web/js/grammar/token/keyword.md) / [variable](/web/js/variable.md) / [global object property](/web/js/scope/global/object/prop.md)
  {% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="info" %}
you can use an [expression](/web/js/grammar/statement/expr.md) to refer to an object's [property](/web/js/val/obj/prop.md)<mark style="color:yellow;">.</mark>&#x20;

👉 [bracket notation \[\]](/web/js/val/obj/prop/access/bracket-notation.md)
{% endhint %}
{% endtab %}

{% tab title="📗 參考" %}

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩&#x20;
  * [ ] 1.3 A Tour of JavaScript
  * [ ] Ch. 4：Expressions & Operators
* [ ] [Expressions versus statements in JavaScript](https://2ality.com/2012/09/expressions-vs-statements.html) ⭐️
* [ ] [Javascript 的表達式 (Expressions) 和陳述式 (Statements)：一個用說的，一個用做的](https://medium.com/itsems-frontend/javascript-expressions-and-statements-7bd374effc95)
  {% endtab %}

{% tab title="📘 手冊" %}

* [ ] [Expressions and operators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators) ⟩ [Primary Expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators#primary_expressions)
  {% endtab %}
  {% endtabs %}
