---
description: creating objects using `new F()` syntax.
---

# new

[JS](../../..) ⟩ [value](../..) ⟩ [object](..) ⟩ [create]() ⟩ new

{% hint style="success" %}
([op](../../../grammar/op "mention")) (:star2: [table-of-operators](../../../grammar/op/table-of-operators "mention"))

create objects by using [**constructor**](../../func/constructor) functions.  (:point\_right: [callable-vs.-constructable](new/callable-vs.-constructable "mention"))

```javascript
new Object() 
new Point(2,3)

new Object        // empty pair of parentheses can be omitted
new Date
```

:u6307: <mark style="color:yellow;">**synonyms**</mark>： "<mark style="color:purple;">**object creation expression**</mark>"
{% endhint %}

{% tabs %}
{% tab title="🧨 雷區" %}
{% hint style="danger" %}
[**class**](../../class) can <mark style="color:red;">**only**</mark>**&#x20;**<mark style="color:yellow;">**be instantiated**</mark> with the <mark style="color:purple;">**`new`**</mark> <mark style="color:yellow;">**operator**</mark> — attempting to call a class <mark style="color:red;">**without**</mark> <mark style="color:purple;">**`new`**</mark> will throw a [<mark style="color:red;">**`TypeError`**</mark>](../../../err/type):exclamation:
{% endhint %}
{% endtab %}

{% tab title="⭐️ 重點" %}
{% hint style="info" %}
<mark style="color:yellow;">**objects**</mark> created by <mark style="color:purple;">**`new F()`**</mark> <mark style="color:yellow;">**use**</mark> [**`F.prototype`**](../../func/prototype) <mark style="color:yellow;">**as**</mark> their [**prototype**](../proto).
{% endhint %}

{% hint style="success" %}
a [**function**](../../func) can know <mark style="color:yellow;">**whether it is invoked with**</mark> <mark style="color:purple;">**new**</mark> by <mark style="color:orange;">**checking**</mark> [**new.target**](new/new.target). [**new.target**](new/new.target) is <mark style="color:red;">**only**</mark> [**undefined**](../../prim/undefined) <mark style="color:yellow;">**when**</mark> the function is <mark style="color:yellow;">**invoked**</mark> <mark style="color:red;">**without**</mark> <mark style="color:purple;">**new**</mark>.
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* [callable-vs.-constructable](new/callable-vs.-constructable "mention")
* [new.target](new/new.target "mention")
{% endtab %}

{% tab title="📗 參考" %}
* [ ] [javascript-the-definitive-guide](../../../../master/ref/javascript-the-definitive-guide "mention") ⟩&#x20;
  * [x] 4.6 Object Creation Expressions
  * [ ] Ch. 9 Classes
{% endtab %}

{% tab title="📘 手冊" %}
* [ ] [new](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new)
{% endtab %}
{% endtabs %}
