diff options
| author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
|---|---|---|
| committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
| commit | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch) | |
| tree | d4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/de/web/javascript/reference/global_objects/string/endswith | |
| parent | 33058f2b292b3a581333bdfb21b8f671898c5060 (diff) | |
| download | translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2 translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip | |
initial commit
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/string/endswith')
| -rw-r--r-- | files/de/web/javascript/reference/global_objects/string/endswith/index.html | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/string/endswith/index.html b/files/de/web/javascript/reference/global_objects/string/endswith/index.html new file mode 100644 index 0000000000..73f37a9692 --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/string/endswith/index.html @@ -0,0 +1,148 @@ +--- +title: String.prototype.endsWith() +slug: Web/JavaScript/Reference/Global_Objects/String/endsWith +tags: + - JavaScript + - Méthode + - Prototyp + - Referenz + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/endsWith +--- +<div>{{JSRef}}</div> + +<p>Die Methode <strong><code>endsWith()</code></strong> bestimmt, ob ein String das Ende eines anderen Strings ist, und liefert entsprechend true oder false zurück.</p> + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox"><var>str</var>.endsWith(<var>suchString</var>[, <var>position</var>])</pre> + +<h3 id="Parameter">Parameter</h3> + +<dl> + <dt><code>suchString</code></dt> + <dd>Der String, nach dem am Ende von str gesucht wird.</dd> + <dt><code>position</code></dt> + <dd>Optional. Durchsucht str, als wäre es nur <strong>position</strong> Zeichen lang. Standardmäßig wird die Länge von str benutzt, wird automatisch auf die Länge von str gebracht, falls diese überschritten wird.</dd> +</dl> + +<h3 id="Rückgabewert">Rückgabewert</h3> + +<p><code>Falls suchString das Ende von str ist, wird </code><strong><code>true</code></strong> zurückgeliefert, andernfalls wird <strong><code>false</code></strong> zurückgeliefert.</p> + +<h2 id="Beschreibung">Beschreibung</h2> + +<p>Diese Methode bestimmt, ob ein String das Ende eines anderen Strings ist. Die Methode unterscheidet zwischen Groß- und Kleinschreibung.</p> + +<h2 id="Beispiele">Beispiele</h2> + +<h3 id="Benutzung_von_endsWith()">Benutzung von <code>endsWith()</code></h3> + +<pre class="brush: js">var str = 'To be, or not to be, that is the question.'; + +console.log(str.endsWith('question.')); // true +console.log(str.endsWith('to be')); // false +console.log(str.endsWith('to be', 19)); // true +</pre> + +<h2 id="Polyfill">Polyfill</h2> + +<p>Diese Methode wurde der ECMAScript6-Spezifikation hinzugefügt und könnte noch nicht in allen JavaScript-Implementierungen verfügbar sein. Mithilfe des folgenden Code-Stücks kann die Methode auch bei fehlender Implementierung genutzt werden:</p> + +<pre class="brush: js">if (!String.prototype.endsWith) { + String.prototype.endsWith = function(searchString, position) { + var subjectString = this.toString(); + if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { + position = subjectString.length; + } + position -= searchString.length; + var lastIndex = subjectString.indexOf(searchString, position); + return lastIndex !== -1 && lastIndex === position; + }; +} +</pre> + +<h2 id="Spezifikation">Spezifikation</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specifikation</th> + <th scope="col">Status</th> + <th scope="col">Kommentar</th> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}}</td> + <td>{{Spec2('ES6')}}</td> + <td>Initiale Definition.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-string.prototype.endswith', 'String.prototype.endsWith')}}</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>Edge</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Grundlegende Unterstützung</td> + <td>{{CompatChrome("41")}}</td> + <td>{{CompatGeckoDesktop("17")}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatSafari("9")}}</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>Grundlegende Unterstützung</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome("36")}}</td> + <td>{{CompatGeckoMobile("17")}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Siehe_auch">Siehe auch</h2> + +<ul> + <li>{{jsxref("String.prototype.startsWith()")}}</li> + <li>{{jsxref("String.prototype.includes()")}}</li> + <li>{{jsxref("String.prototype.indexOf()")}}</li> + <li>{{jsxref("String.prototype.lastIndexOf()")}}</li> +</ul> |
