aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/string/slice
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/string/slice')
-rw-r--r--files/de/web/javascript/reference/global_objects/string/slice/index.html152
1 files changed, 152 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/string/slice/index.html b/files/de/web/javascript/reference/global_objects/string/slice/index.html
new file mode 100644
index 0000000000..d30b18e21f
--- /dev/null
+++ b/files/de/web/javascript/reference/global_objects/string/slice/index.html
@@ -0,0 +1,152 @@
+---
+title: String.prototype.slice()
+slug: Web/JavaScript/Reference/Global_Objects/String/slice
+translation_of: Web/JavaScript/Reference/Global_Objects/String/slice
+---
+<div>{{JSRef}}</div>
+
+<p>Die <strong><code>slice()</code></strong> Methode extrahiert einen Teilbereich eines Strings und gibt einen neuen String zurück.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox"><code><var>str</var>.slice(<var>AnfangIndex</var>[, E<var>ndIndex</var>])</code></pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt><code>AnfangIndex</code></dt>
+ <dd>Der nullbasierte Index von welchem mit der Extraktion begonnen wird. Wenn dieser negativ ist, wird er als <code>strLength + AnfangIndex, </code>wobei <code>strLength</code> die länge des Strings darstellt, (bspw., wenn <code>AnfangIndex</code>  <code>-3</code> ist, wird es als <code>strLength - 3 gewertet</code>). Wenn <code>beginIndex</code><em> </em>größer oder gleich length des Strings ist, gibt <code>slice()</code> einen leeren String zurück.</dd>
+ <dt><code>EndIndex</code></dt>
+ <dd>Optional. Der nullbasierte Index <em>vor</em> welchem  die Extraktion beendet wird. Der Charakter an diesem Index wird nicht mit einbezogen. Wenn <code>EndIndex </code>ausgelassen wird, extrahiert <code>slice()</code> bis zum Ende des Strings. Wenn <code>EndIndex </code>negativ ist, wird es wie <code>strLength + EndIndex</code> gewertet, wobei strLength sich auf die Länge des Strings bezieht (z.B.: wenn E<code>ndIndex</code>  <code>-3 ist, wird es gewertet wie </code><code>strLength - 3).</code></dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>Ein neuer String, welcher die extrahierte Sektion des Strings enthält.</p>
+
+<h2 id="Beschreibung">Beschreibung</h2>
+
+<p><code>slice()</code> extrahiert den Text eines Strings und gibt einen neuen zurück. Änderungen im einen String wirken sich nicht auf den anderen String aus.</p>
+
+<p><code>slice()</code> extrahiert bis, aber nicht einschließlich, <code>EndIndex. </code><code>str.slice(1, 4)</code> extrahiert den zweiten Charakter bis zum vierten  (Character mit den Indexen 1, 2, und 3).</p>
+
+<p>Als Beispiel, <code>str.slice(2, -1)</code> extrahiert den dritten Charakter bis zum zweiten, bis zum letzten Charakter im String.</p>
+
+<h2 id="Beispiele">Beispiele</h2>
+
+<h3 id="Benutzen_von_slice()_um_einen_neuen_String_zu_erzeugen"><code>Benutzen von slice()</code> um einen neuen String zu erzeugen</h3>
+
+<p>Das folgende Beispiel benutzt <code>slice()</code> um einen neuen String zu erzeugen.</p>
+
+<pre class="brush: js">var str1 = 'The morning is upon us.', // the length of str1 is 23.
+ str2 = str1.slice(1, 8),
+ str3 = str1.slice(4, -2),
+  str4 = str1.slice(12),
+ str5 = str1.slice(30);
+console.log(str2); // OUTPUT: he morn
+console.log(str3); // OUTPUT: morning is upon u
+console.log(str4); // OUTPUT: is upon us.
+console.log(str5); // OUTPUT: ""
+</pre>
+
+<h3 id="Benutzen_von_slice()_mit_negativen_Indexen">Benutzen von <code>slice()</code> mit negativen Indexen</h3>
+
+<p>Das folgende Beispiel benutzt <code>slice()</code> mit negativen Indexen.</p>
+
+<pre class="brush: js">var str = 'The morning is upon us.';
+str.slice(-3); // returns 'us.'
+str.slice(-3, -1); // returns 'us'
+str.slice(0, -1); // returns 'The morning is upon us'
+</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('ES3')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>Initiale Definition. Implementiert in JavaScript 1.2.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.5.4.13', 'String.prototype.slice')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-string.prototype.slice', 'String.prototype.slice')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.prototype.slice', 'String.prototype.slice')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_kompatibilität">Browser kompatibilität</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</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>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{jsxref("String.prototype.substr()")}}</li>
+ <li>{{jsxref("String.prototype.substring()")}}</li>
+ <li>{{jsxref("Array.prototype.slice()")}}</li>
+</ul>