diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:45 -0500 |
| commit | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (patch) | |
| tree | 0dd8b084480983cf9f9680e8aedb92782a921b13 /files/es/web/javascript/reference/global_objects/reflect | |
| parent | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (diff) | |
| download | translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.gz translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.tar.bz2 translated-content-1109132f09d75da9a28b649c7677bb6ce07c40c0.zip | |
initial commit
Diffstat (limited to 'files/es/web/javascript/reference/global_objects/reflect')
| -rw-r--r-- | files/es/web/javascript/reference/global_objects/reflect/index.html | 137 | ||||
| -rw-r--r-- | files/es/web/javascript/reference/global_objects/reflect/set/index.html | 148 |
2 files changed, 285 insertions, 0 deletions
diff --git a/files/es/web/javascript/reference/global_objects/reflect/index.html b/files/es/web/javascript/reference/global_objects/reflect/index.html new file mode 100644 index 0000000000..a2f9d12fb7 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/reflect/index.html @@ -0,0 +1,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> diff --git a/files/es/web/javascript/reference/global_objects/reflect/set/index.html b/files/es/web/javascript/reference/global_objects/reflect/set/index.html new file mode 100644 index 0000000000..10436d8928 --- /dev/null +++ b/files/es/web/javascript/reference/global_objects/reflect/set/index.html @@ -0,0 +1,148 @@ +--- +title: Reflect.set() +slug: Web/JavaScript/Reference/Global_Objects/Reflect/set +translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/set +--- +<div>{{JSRef}}</div> + +<p>El método estático <code><strong>Reflect</strong></code><strong><code>.set()</code></strong> funciona igual que asignar una propiedad en un objeto.</p> + +<h2 id="Sintaxis">Sintaxis</h2> + +<pre class="syntaxbox">Reflect.set(target, propertyKey, value[, receiver]) +</pre> + +<h3 id="Parámetros">Parámetros</h3> + +<dl> + <dt><code>target</code></dt> + <dd>El objeto en el cual se va a asignar una propiedad.</dd> + <dt><code>propertyKey</code></dt> + <dd>El nombre de la propiedad a asignar.</dd> + <dt>value</dt> + <dd>El valor de la propiedad.</dd> + <dt>receiver</dt> + <dd>El valor de <code>this</code> para usar en la llamada a <code>target</code> si se encuentra un setter.</dd> +</dl> + +<h3 id="Valor_de_retorno">Valor de retorno</h3> + +<p>Un {{jsxref("Boolean")}} indicando si se pudo o no asignar la propiedad.</p> + +<h3 id="Excepciones">Excepciones</h3> + +<p>Un {{jsxref("TypeError")}}, si <code>target</code> no es un {{jsxref("Object")}}.</p> + +<h2 id="Descripción">Descripción</h2> + +<p>El método <code>Reflect.set</code> permite asignar una propiedad a un objeto. It does property assignment and is like the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors">property accessor</a> syntax as a function.</p> + +<h2 id="Ejemplos">Ejemplos</h2> + +<h3 id="Uso_de_Reflect.set()"><code><font face="x-locale-heading-primary, zillaslab, Palatino, Palatino Linotype, x-locale-heading-secondary, serif">Uso de </font>Reflect.set()</code></h3> + +<pre class="brush: js">// Objeto +var obj = {}; +Reflect.set(obj, 'prop', 'value'); // true +obj.prop; // "value" + +// Arreglo +var arr = ['duck', 'duck', 'duck']; +Reflect.set(arr, 2, 'goose'); // true +arr[2]; // "goose" + +// Puede truncar un arreglo. +Reflect.set(arr, 'length', 1); // true +arr; // ["duck"]; + +// Con solo un argumento, propertyKey y value son "undefined". +var obj = {}; +Reflect.set(obj); // true +Reflect.getOwnPropertyDescriptor(obj, 'undefined'); +// { value: undefined, writable: true, enumerable: true, configurable: true } +</pre> + +<h2 id="Especificaciones">Especificaciones</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificación</th> + <th scope="col">Estado</th> + <th scope="col">Comentarios</th> + </tr> + <tr> + <td>{{SpecName('ES2015', '#sec-reflect.set', 'Reflect.set')}}</td> + <td>{{Spec2('ES2015')}}</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-reflect.set', 'Reflect.set')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidad_con_navegadores">Compatibilidad con navegadores</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Soporte básico</td> + <td>49</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoDesktop(42)}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>10</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</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>Soporte básico</td> + <td>{{CompatNo}}</td> + <td>49</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile(42)}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>10</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Ver_también">Ver también</h2> + +<ul> + <li>{{jsxref("Reflect")}}</li> + <li><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors">Property accessors</a></li> +</ul> |
