> 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/val/obj/create/new.md).

# new

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [object](/web/js/val/obj.md) ⟩ [create](/web/js/val/obj/create.md) ⟩ new

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

create objects by using [**constructor**](/web/js/val/func/constructor.md) functions.  (:point\_right: [callable vs. constructable](/web/js/val/obj/create/new/callable-vs.-constructable.md))

```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**](/web/js/val/class.md) 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>](/web/js/err/type.md):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`**](/web/js/val/func/prototype.md) <mark style="color:yellow;">**as**</mark> their [**prototype**](/web/js/val/obj/proto.md).
{% endhint %}

{% hint style="success" %}
a [**function**](/web/js/val/func.md) 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**](/web/js/val/obj/create/new/new.target.md). [**new.target**](/web/js/val/obj/create/new/new.target.md) is <mark style="color:red;">**only**</mark> [**undefined**](/web/js/val/prim/undefined.md) <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](/web/js/val/obj/create/new/callable-vs.-constructable.md)
* [new.target](/web/js/val/obj/create/new/new.target.md)
  {% endtab %}

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

* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩&#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 %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lochiwei.gitbook.io/web/js/val/obj/create/new.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
