aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/reflect/apply/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/reflect/apply/index.html')
-rw-r--r--files/de/web/javascript/reference/global_objects/reflect/apply/index.html98
1 files changed, 98 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/reflect/apply/index.html b/files/de/web/javascript/reference/global_objects/reflect/apply/index.html
new file mode 100644
index 0000000000..bc16c4d4d8
--- /dev/null
+++ b/files/de/web/javascript/reference/global_objects/reflect/apply/index.html
@@ -0,0 +1,98 @@
+---
+title: Reflect.apply()
+slug: Web/JavaScript/Reference/Global_Objects/Reflect/apply
+translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/apply
+---
+<div>{{JSRef}}</div>
+
+<div>Die statische Methode <code><strong>Reflect</strong></code><strong><code>.apply()</code></strong> ruft eine Zielfunktion mit den spezifizierten Parametern auf.</div>
+
+<div> </div>
+
+<div>{{EmbedInteractiveExample("pages/js/reflect-apply.html")}}</div>
+
+
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">Reflect.apply(target, thisParameter, listeDerArgumente)
+</pre>
+
+<h3 id="Parameter">Parameter</h3>
+
+<dl>
+ <dt>target</dt>
+ <dd>Die Funktion, die aufgerufen werden soll.</dd>
+ <dt>thisParameter</dt>
+ <dd>Der Wert von <code>this</code> der für den Aufruf bereitgestellt wird.</dd>
+ <dt>listeDerArgumente</dt>
+ <dd>Ein Array ähnliches Objekt welches die Parameter spezifiziert, mit denen die Zielfunktion aufgerufen wird.</dd>
+</dl>
+
+<h3 id="Rückgabewert">Rückgabewert</h3>
+
+<p>Das Resultat des Aufruft, der Zielfunktion mit dem mitgegebenen <code>this</code> und den mitgegebenen Parametern.</p>
+
+<h3 id="Ausnahmen">Ausnahmen</h3>
+
+<p>Es wird ein {{jsxref("TypeError")}} geworfen, wenn die Zielfunktion nicht aufrufbar ist.</p>
+
+<h2 id="Beschreibung">Beschreibung</h2>
+
+<p>In ES5, ruft man typischerweise {{jsxref("Function.prototype.apply()")}} auf, um eine Funktion aufzurufen, der man einen bestimmten <code>this</code> mitgeben und die Parameter als Array (oder einem <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Working_with_array-like_objects">array-like object</a>) definieren möchte.</p>
+
+<pre class="brush: js">Function.prototype.apply.call(Math.floor, undefined, [1.75]);</pre>
+
+<p>Durch <code>Reflect.apply</code> wird dieses Vorhaben kürzer und ist leichter zu verstehen.</p>
+
+<h2 id="Beispiele">Beispiele</h2>
+
+<h3 id="Verwendung_von_Reflect.apply()">Verwendung von <code>Reflect.apply()</code></h3>
+
+<pre class="brush: js">Reflect.apply(Math.floor, undefined, [1.75]);
+// 1;
+
+Reflect.apply(String.fromCharCode, undefined, [104, 101, 108, 108, 111]);
+// "hello"
+
+Reflect.apply(RegExp.prototype.exec, /ab/, ['confabulation']).index;
+// 4
+
+Reflect.apply(''.charAt, 'ponies', [3]);
+// "i"
+</pre>
+
+<h2 id="Spezifikationen">Spezifikationen</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Spezifikation</th>
+ <th scope="col">Status</th>
+ <th scope="col">Kommentar</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES2015', '#sec-reflect.apply', 'Reflect.apply')}}</td>
+ <td>{{Spec2('ES2015')}}</td>
+ <td>Ursprüngliche Definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-reflect.apply', 'Reflect.apply')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_kompabilität">Browser kompabilität</h2>
+
+
+
+<p>{{Compat("javascript.builtins.Reflect.apply")}}</p>
+
+<h2 id="Siehe_auch">Siehe auch</h2>
+
+<ul>
+ <li>{{jsxref("Reflect")}}</li>
+ <li>{{jsxref("Function.prototype.apply()")}}</li>
+</ul>