# polymorphism

{% hint style="success" %} <mark style="color:purple;">**polymorphism**</mark> means "<mark style="color:yellow;">**same**</mark> [method](/web/js/val/obj/method.md) <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>

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


---

# Agent Instructions: 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/method/polymorphism.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.
