> 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/func/constructor.md).

# constructor

[JS](/web/js.md) ⟩ [value](/web/js/val.md) ⟩ [function](/web/js/val/func.md) ⟩ constructor

{% hint style="success" %}
a [function](/web/js/val/func.md) that supports the [\[\[Construct\]\]](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects) [**internal method**](/web/js/val/obj/prop/internal.md), that is, a [**constructable**](/web/js/val/obj/create/new/callable-vs.-constructable.md) function.
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="success" %} <mark style="color:yellow;">**function vs.**</mark>**&#x20;**<mark style="color:purple;">**constructor**</mark>

* [function](/web/js/val/func.md)：
  * [object](/web/js/val/obj.md) that supports the [\[\[Call\]\]](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects) internal method.&#x20;
* <mark style="color:purple;">**constructor**</mark>：&#x20;
  * object that supports the [\[\[Construct\]\]](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects) internal method.&#x20;
  * every <mark style="color:purple;">**constructor**</mark> must support [\[\[Call\]\]](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects) (that is, every <mark style="color:purple;">**constructor**</mark> is a <mark style="color:yellow;">**function**</mark>)

👉 ES2023 ⟩ [Additional Essential Internal Methods of Function Objects](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects)
{% endhint %}

{% hint style="warning" %}
👉 <mark style="color:orange;">**compare**</mark>：

* the [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor) [method](/web/js/val/obj/method.md) of a [class](/web/js/val/class.md).
* the [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) [property](/web/js/val/obj/prop.md) present on all [object](/web/js/val/obj.md)s.
  {% endhint %}
  {% endtab %}

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

* a <mark style="color:purple;">**constructor**</mark> is a [function](/web/js/val/func.md).
* [callable vs. constructable](/web/js/val/obj/create/new/callable-vs.-constructable.md).
  {% endtab %}

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

* ES2023 ⟩ [Additional Essential Internal Methods of Function Objects](https://tc39.es/ecma262/#table-additional-essential-internal-methods-of-function-objects)
* [Object.prototype.constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)
  {% endtab %}

{% tab title="❓" %}
{% hint style="warning" %}
what a constructor actually is in plain JS ❓

(what does the part "supports the \[\[Construct]] internal method" really mean?)
{% endhint %}
{% endtab %}
{% endtabs %}
