diff options
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/string/lastindexof/index.html')
| -rw-r--r-- | files/de/web/javascript/reference/global_objects/string/lastindexof/index.html | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/string/lastindexof/index.html b/files/de/web/javascript/reference/global_objects/string/lastindexof/index.html new file mode 100644 index 0000000000..b6c6f3a548 --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/string/lastindexof/index.html @@ -0,0 +1,148 @@ +--- +title: String.prototype.lastIndexOf() +slug: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf +translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf +--- +<div>{{JSRef("Global_Objects", "String")}}</div> + +<h2 id="Summary" name="Summary">Zusammenfassung</h2> + +<p>Die <strong><code>lastIndexOf()</code></strong> Methode gibt den Index des letzten Vorkommnisses des angegebenen Wertes innerhalb des aufrufenden {{jsxref("Global_Objects/String", "Strings")}} Objekts zurück, oder -1, wenn der Wert nicht gefunden wurde. Der aufrufende String wird rückwärts durchsucht, beginnend beim <code>fromIndex</code>. </p> + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="syntaxbox"><code><var>str</var>.lastIndexOf(<var>searchValue</var>[, <var>fromIndex</var>])</code></pre> + +<h3 id="Parameters" name="Parameters">Parameter</h3> + +<dl> + <dt><code>searchValue</code></dt> + <dd>Ein String mit dem Wert, nach dem gesucht werden soll.</dd> + <dt><code>fromIndex</code></dt> + <dd>Optional. Die Position im aufrufenden String, ab der gesucht rückwärts werden soll. The Position wird gezählt von links nach rechts. Gesucht wird von dieser Position ab nach links. Diese kann jeden Integerwert annehmen. Der Standartwert ist <code>str.length</code>. Wenn der Wert negativ ist, wird 0 verwendet. Wenn <code>fromIndex > str.length</code>, wird <code>str.length </code>statt <code>fromIndex</code> benutzt.</dd> +</dl> + +<h2 id="Description" name="Description">Beschreibung</h2> + +<p>Zeichen in einem String werden von links nach rechts gezählt. Der Index des ersten Zeichens ist 0, der Index des letzten Zeichens ist <code>stringName.length - 1</code>.</p> + +<pre class="brush: js">'canal'.lastIndexOf('a'); // returns 3 +'canal'.lastIndexOf('a', 2); // returns 1 +'canal'.lastIndexOf('a', 0); // returns -1 +'canal'.lastIndexOf('x'); // returns -1 +</pre> + +<h3 id="Case-sensitivity" name="Case-sensitivity">Groß- und Kleinschreibung</h3> + +<p>Die <code>lastIndexOf() </code>Methode unterscheidet zwischen Groß- und Kleinschreibung. Der folgende Ausdruck gibt zum Beispiel <code>-1</code> zurück.</p> + +<pre class="brush: js">'Blue Whale, Killer Whale'.lastIndexOf('blue'); // returns -1 +</pre> + +<h2 id="Examples" name="Examples">Beispiele</h2> + +<h3 id="Example:_Using_indexOf_and_lastIndexOf" name="Example:_Using_indexOf_and_lastIndexOf">Beispiel: Benutzung von <code>indexOf()</code> und <code>lastIndexOf()</code></h3> + +<p>Das folgende Beispiel verwendet {{jsxref("String.prototype.indexOf()", "indexOf()")}} und <code>lastIndexOf(),</code> um Werte im String <code>"Brave new world" zu finden</code>.</p> + +<pre class="brush: js">var anyString = 'Brave new world'; + +console.log('The index of the first w from the beginning is ' + anyString.indexOf('w')); +// Displays 8 +console.log('The index of the first w from the end is ' + anyString.lastIndexOf('w')); +// Displays 10 + +console.log('The index of "new" from the beginning is ' + anyString.indexOf('new')); +// Displays 6 +console.log('The index of "new" from the end is ' + anyString.lastIndexOf('new')); +// Displays 6 +</pre> + +<h2 id="Spezifikationen">Spezifikationen</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>ECMAScript 1st Edition.</td> + <td>Standard</td> + <td>Initial definition.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.5.4.8', 'String.prototype.lastIndexOf')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-string.prototype.lastindexof', 'String.prototype.lastIndexOf')}}</td> + <td>{{Spec2('ES6')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browserkompatibilität">Browserkompatibilitä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" name="See_also">Links</h2> + +<ul> + <li>{{jsxref("String.prototype.charAt()")}}</li> + <li>{{jsxref("String.prototype.indexOf()")}}</li> + <li>{{jsxref("String.prototype.split()")}}</li> + <li>{{jsxref("Array.prototype.indexOf()")}}</li> + <li>{{jsxref("Array.prototype.lastIndexOf()")}}</li> +</ul> |
