---
description: 🚧 under construction
---

# function overloading

[JS](../..) ⟩ [value](..) ⟩ [function]() ⟩ overloading

{% hint style="danger" %}
there is <mark style="color:red;">**NO**</mark>**&#x20;**<mark style="color:purple;">**function overloading**</mark> in <mark style="color:yellow;">**JavaScript**</mark>:exclamation:
{% endhint %}

{% hint style="success" %}
<mark style="color:yellow;">**same**</mark> [name](name "mention")，<mark style="color:red;">**different**</mark> [param](param "mention")(s).
{% endhint %}

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

* [overload](overload "mention")：<mark style="color:yellow;">**same**</mark> [name](name "mention"), <mark style="color:red;">**different**</mark> [param](param "mention")(s).
* [polymorphism](../obj/method/polymorphism "mention")：<mark style="color:yellow;">**same**</mark> [method](../obj/method "mention") <mark style="color:yellow;">**name**</mark>, <mark style="color:red;">**different**</mark>**&#x20;**<mark style="color:yellow;">**callers**</mark><mark style="color:red;">**.**</mark>
{% endhint %}
{% endtab %}

{% tab title="👥 相關" %}
* don't confuse with [polymorphism](../obj/method/polymorphism "mention") (<mark style="color:yellow;">**same method name**</mark>, <mark style="color:red;">**different callers**</mark>).
* :point\_right: <mark style="color:yellow;">**compare**</mark>： [typescript](../../../appendix/typescript "mention") ⟩ [function-overloads](../../../appendix/typescript/type/function/function-overloads "mention").
{% endtab %}

{% tab title="📗 參考" %}
* [ ] John Resig ⟩ [JavaScript Method Overloading](https://johnresig.com/blog/javascript-method-overloading/) \
  利用<mark style="color:yellow;">**參數數目的不同**</mark>來執行不同的任務。
* [ ] DEV ⟩ [Simulated Function Overloading in JavaScript](https://dev.to/joelnet/simulated-function-overloading-in-javascript-1l0o)
{% endtab %}

{% tab title="🗣 討論" %}
* [Help with JS and functions parameters](https://stackoverflow.com/a/2187697/5409815)\
  利用參數數目的不同或參數型別不同來執行不同程序。
* [Function overloading in Javascript - Best practices \[closed\]](https://stackoverflow.com/questions/456177/function-overloading-in-javascript-best-practices)\
  推薦參數最後放一個 [options](../../grammar/op/assign/destruct/obj) 物件就好。\

{% endtab %}

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