---
description: same method name, different callers.
---

# polymorphism

{% hint style="success" %}
<mark style="color:purple;">**polymorphism**</mark> means "<mark style="color:yellow;">**same**</mark> [](<> "mention") <mark style="color:yellow;">**name**</mark>, <mark style="color:red;">**different**</mark>**&#x20;**<mark style="color:yellow;">**callers**</mark>".

```javascript
dog.speak()    // caller: dog
cat.speak()    // caller: cat
```
{% endhint %}

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

* [overload](../../func/overload "mention")：<mark style="color:yellow;">**same**</mark> [name](../../func/name "mention"), <mark style="color:red;">**different**</mark> [param](../../func/param "mention")(s).
* [polymorphism](polymorphism "mention")：<mark style="color:yellow;">**same**</mark> [](<> "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 [overload](../../func/overload "mention")(<mark style="color:yellow;">**same function name**</mark>, <mark style="color:red;">**different parameters**</mark>).
{% endtab %}
{% endtabs %}
