aboutsummaryrefslogtreecommitdiff
path: root/files/es/web/javascript/reference/global_objects/reflect/set
diff options
context:
space:
mode:
Diffstat (limited to 'files/es/web/javascript/reference/global_objects/reflect/set')
-rw-r--r--files/es/web/javascript/reference/global_objects/reflect/set/index.html148
1 files changed, 148 insertions, 0 deletions
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>