diff options
Diffstat (limited to 'files/zh-tw/web/javascript/reference/global_objects/reflect/index.html')
-rw-r--r-- | files/zh-tw/web/javascript/reference/global_objects/reflect/index.html | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html b/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html new file mode 100644 index 0000000000..4f1d980a0d --- /dev/null +++ b/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html @@ -0,0 +1,130 @@ +--- +title: Reflect +slug: Web/JavaScript/Reference/Global_Objects/Reflect +translation_of: Web/JavaScript/Reference/Global_Objects/Reflect +--- +<div>{{JSRef}}</div> + +<p><strong>Reflect</strong> 是一個內建物件,提供了用於獲取可截取之 JavaScript 操作的方法。這些方法與 <a href="/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler">proxy handlers</a> 的方法相同。<code>Reflect</code> 不是一個函式物件,因此它是不可建構的。</p> + +<h2 id="描述">描述</h2> + +<p>Unlike most global objects, <code>Reflect</code> is not a constructor. You can not use it with a <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code> operator</a> or invoke the <code>Reflect</code> object as a function. All properties and methods of <code>Reflect</code> are static (just like the {{jsxref("Math")}} object).</p> + +<h2 id="方法">方法</h2> + +<p>The <code>Reflect</code> object provides the following static functions which have the same names as the <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler">proxy handler methods</a>. Some of these methods are the same as corresponding methods on {{jsxref("Object")}}.</p> + +<dl> + <dt>{{jsxref("Reflect.apply()")}}</dt> + <dd>Calls a target function with arguments as specified by the <code>args</code> parameter. See also {{jsxref("Function.prototype.apply()")}}.</dd> + <dt>{{jsxref("Reflect.construct()")}}</dt> + <dd> The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code> operator</a> as a function. Equivalent to calling <code>new target(...args)</code>.</dd> + <dt>{{jsxref("Reflect.defineProperty()")}}</dt> + <dd>Similar to {{jsxref("Object.defineProperty()")}}. Returns a {{jsxref("Boolean")}}.</dd> + <dt>{{jsxref("Reflect.deleteProperty()")}}</dt> + <dd>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/delete"><code>delete</code> operator</a> as a function. Equivalent to calling <code>delete target[name]</code>.</dd> + <dt>{{jsxref("Reflect.get()")}}</dt> + <dd>A function that returns the value of properties.</dd> + <dt>{{jsxref("Reflect.getOwnPropertyDescriptor()")}}</dt> + <dd>Similar to {{jsxref("Object.getOwnPropertyDescriptor()")}}. Returns a property descriptor of the given property if it exists on the object, {{jsxref("undefined")}} otherwise.</dd> + <dt>{{jsxref("Reflect.getPrototypeOf()")}}</dt> + <dd>Same as {{jsxref("Object.getPrototypeOf()")}}.</dd> + <dt>{{jsxref("Reflect.has()")}}</dt> + <dd>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/in"><code>in</code> operator</a> as function. Returns a boolean indicating whether an own or inherited property exists.</dd> + <dt>{{jsxref("Reflect.isExtensible()")}}</dt> + <dd>Same as {{jsxref("Object.isExtensible()")}}.</dd> + <dt>{{jsxref("Reflect.ownKeys()")}}</dt> + <dd>Returns an array of the target object's own (not inherited) property keys.</dd> + <dt>{{jsxref("Reflect.preventExtensions()")}}</dt> + <dd>Similar to {{jsxref("Object.preventExtensions()")}}. Returns a {{jsxref("Boolean")}}.</dd> + <dt>{{jsxref("Reflect.set()")}}</dt> + <dd>A function that assigns values to properties. Returns a {{jsxref("Boolean")}} that is <code>true</code> if the update was successful.</dd> + <dt>{{jsxref("Reflect.setPrototypeOf()")}}</dt> + <dd>A function that sets the prototype of an object.</dd> +</dl> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('ES2015', '#sec-reflect-object', 'Reflect')}}</td> + <td>{{Spec2('ES2015')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-reflect-object', 'Reflect')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td>Reflect.enumerate has been removed.</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatChrome(49.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop("42")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatSafari(10)}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatChrome(49.0)}}</td> + <td>{{CompatChrome(49.0)}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile("42")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatSafari(10)}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="參見">參見</h2> + +<ul> + <li>The {{jsxref("Proxy")}} global object.</li> + <li>The {{jsxref("Proxy.handler", "handler")}} object.</li> +</ul> |