aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/javascript/reference/global_objects/reflect/index.html
blob: a2f9d12fb73ccf43b43cb07eb91129fae845636d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
title: Reflect
slug: Web/JavaScript/Reference/Global_Objects/Reflect
tags:
  - ECMAScript 2015
  - JavaScript
  - NeedsTranslation
  - Overview
  - Reflect
  - TopicStub
translation_of: Web/JavaScript/Reference/Global_Objects/Reflect
---
<div>{{JSRef}}</div>

<p><strong>Reflect </strong> es un objecto incorporado que proporciona metodos para interceptar operaciones de javascript. Los métodos son los mismos que los de <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler">proxy handlers</a>. <code>Reflect</code> no es un objeto de funciones y por lo tanto no puede ser construido.</p>

<h2 id="Descripción">Descripción</h2>

<p>A diferencia de la mayoria de los objetos globales, <code>Reflect</code> no es un constructor.  No puede ser instanciado con un <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new">operador</a> <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code> </a>o invocando el objecto  <code>Reflect</code> como una función. Todas las propiedades y métodos de <code>Reflect</code> son estáticos (igual que los del objeto {{jsxref("Math")}}).</p>

<h2 id="Métodos">Métodos</h2>

<p>El objeto <code>Reflect</code>  proporciona las siguientes funciones estáticas con los mismos nombres de los métodos de <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler">proxy handler</a>. Algunos de estos métodos son correspondientes a los métodos de {{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="Especificaciones">Especificaciones</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="Compatibilidad_en_Navegadores">Compatibilidad en Navegadores</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="También_ver">También ver</h2>

<ul>
 <li>The {{jsxref("Proxy")}} global object.</li>
 <li>The {{jsxref("Proxy.handler", "handler")}} object.</li>
</ul>