> 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/builtin/proxy/reflect.md).

# Reflect

[JS](/web/js.md) ⟩ [object](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ Reflect

{% hint style="success" %}
A built-in object that <mark style="color:yellow;">**provides methods**</mark> for <mark style="color:yellow;">**interceptable**</mark> operations. The methods are the same as those of [proxy handlers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy).&#x20;
{% endhint %}

{% tabs %}
{% tab title="⭐️ 重點" %}
{% hint style="warning" %} <mark style="color:purple;">**Reflect**</mark> <mark style="color:yellow;">**is**</mark>**&#x20;**<mark style="color:red;">**not**</mark> a [**function**](/web/js/val/func.md) object, so it's <mark style="color:red;">**not**</mark>**&#x20;**<mark style="color:yellow;">**constructible**</mark>:exclamation:
{% endhint %}

{% hint style="info" %}
the <mark style="color:yellow;">**first parameter**</mark> to all the Reflect methods is called the <mark style="color:blue;">**target**</mark> parameter.
{% endhint %}
{% endtab %}

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

* [ ] JS.info ⟩ [Proxy and Reflect](https://javascript.info/proxy)
* [ ] [JavaScript: The Definitive Guide](/web/master/ref/javascript-the-definitive-guide.md) ⟩ 14.6 The Reflect API
  {% endtab %}

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

* [Reflect](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect)
* [Proxy](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy)
  {% endtab %}

{% tab title="🗣 討論" %}

* [What is the purpose of Reflect.get method's third parameter in JavaScript](https://stackoverflow.com/questions/63626532/what-is-the-purpose-of-reflect-get-methods-third-parameter-in-javascript)
  {% endtab %}
  {% endtabs %}

<table><thead><tr><th width="310.3333333333333">Reflect.method()</th><th>Triggers when…</th></tr></thead><tbody><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/apply">apply</a>(f, o, args)</td><td><ul><li>invokes <mark style="color:blue;"><code>f</code></mark> <mark style="color:yellow;"><strong>as a method</strong></mark> of <mark style="color:blue;"><code>o</code></mark> , just like <mark style="color:yellow;"><code>o.f(args)</code></mark>.</li><li>same as <mark style="color:orange;"><code>f.apply(o, args)</code></mark>.</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct">construct</a>(C, args, newTarget)</td><td><ul><li>invokes <mark style="color:blue;"><code>C</code></mark> <mark style="color:yellow;"><strong>as a constructor</strong></mark>.</li><li>same as <mark style="color:orange;"><code>new C(...args)</code></mark>.</li><li><code>newTarget</code> is used as <a href="/web/js/val/obj/create/new/new.target.md"><strong>new.target</strong></a> (if specified).</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty">defineProperty</a>(o, key, desc)</td><td><ul><li><mark style="color:yellow;"><strong>define</strong></mark> new/existing <mark style="color:yellow;"><strong>property</strong></mark>.</li><li>similar to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty">Object.defineProperty</a>(o, key, desc).</li><li>but returns boolean.</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/deleteProperty">deleteProperty</a>(o, key)</td><td><ul><li><mark style="color:yellow;"><strong>delete</strong></mark> a <mark style="color:yellow;"><strong>property</strong></mark>.</li><li>similar to <mark style="color:orange;"><code>delete o[key]</code></mark>.</li><li>returns boolean.</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/get">get</a>(o, key, receiver)</td><td><ul><li><mark style="color:yellow;"><strong>get</strong></mark> a <mark style="color:yellow;"><strong>property</strong></mark>.</li><li>similar to <mark style="color:orange;"><code>o[key]</code></mark>.</li><li>(<a href="https://stackoverflow.com/questions/63626532/what-is-the-purpose-of-reflect-get-methods-third-parameter-in-javascript">not sure</a> what the <code>receiver</code> is for. <span data-gb-custom-inline data-tag="emoji" data-code="1f615">😕</span>) <span data-gb-custom-inline data-tag="emoji" data-code="2753">❓</span></li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getOwnPropertyDescriptor">getOwnPropertyDescriptor</a>(o, key)</td><td><ul><li><mark style="color:yellow;"><strong>get</strong></mark> a <a href="/web/js/val/obj/prop/attr/property-descriptor.md"><strong>property descriptor</strong></a>.</li><li>(almost) same as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor">Object.getOwnPropertyDescriptor</a>(o, key)</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/getPrototypeOf">getPrototypeOf</a>(o)</td><td><ul><li><mark style="color:yellow;"><strong>get</strong></mark> the <a href="/web/js/val/obj/proto.md"><strong>prototype</strong></a> of an object.</li><li>(almost) same as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf">Object.getPrototypeOf</a>(o).</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/has">has</a>(o, key)</td><td><ul><li>check if object <mark style="color:blue;"><code>o</code></mark> <mark style="color:yellow;"><strong>has property</strong></mark> <mark style="color:blue;"><code>key</code></mark>.</li><li>similar to <mark style="color:orange;"><code>key in o</code></mark>.</li><li>returns <mark style="color:green;"><code>true</code></mark> for any <mark style="color:yellow;"><strong>inherited</strong></mark> properties.</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible">isExtensible</a>(o)</td><td><ul><li>check if an object is <mark style="color:yellow;"><strong>extensible</strong></mark>.</li><li>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/isExtensible#difference_with_object.isextensible">almost</a>) same as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isExtensible">Object.isExtensible</a>(o)</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys">ownKeys</a>(o)</td><td><ul><li>returns an array of <mark style="color:red;"><strong>own</strong></mark> <mark style="color:yellow;"><strong>property</strong></mark> <mark style="color:yellow;"><strong>keys</strong></mark>.<br>(string/symbol included)</li><li>similar to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames">Object.getOwnPropertyNames</a>(o) + <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols">Object.getOwnPropertySymbols</a>(o).</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions">preventExtensions</a>(o)</td><td><ul><li><mark style="color:yellow;"><strong>prevents</strong></mark> <mark style="color:yellow;"><strong>new properties</strong></mark> from being added to an object.</li><li>(<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/preventExtensions#difference_with_object.preventextensions">almost</a>) same as <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/preventExtensions">Object.preventExtensions</a>(o)</li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set">set</a>(o, key, value, receiver)</td><td><ul><li>set a property.</li><li>similar to <mark style="color:orange;"><code>o[key] = value</code></mark>.</li><li>returns boolean.</li><li>(not sure what the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/set#different_target_and_receiver">receiver</a> is for <span data-gb-custom-inline data-tag="emoji" data-code="1f615">😕</span>) <span data-gb-custom-inline data-tag="emoji" data-code="2753">❓</span></li></ul></td></tr><tr><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/setPrototypeOf">setPrototypeOf</a>(o, p)</td><td><ul><li><mark style="color:yellow;"><strong>set</strong></mark> the <a href="/web/js/val/obj/proto.md"><strong>prototype</strong></a> of an object. (<mark style="color:red;"><strong>not</strong></mark><strong> </strong><mark style="color:yellow;"><strong>recommended</strong></mark>)</li><li>similar to <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf">Object.setPrototypeOf</a>(o, p).</li><li>returns boolean.</li></ul></td></tr></tbody></table>
