diff options
author | Florian Dieminger <me@fiji-flo.de> | 2021-02-11 18:20:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 18:20:22 +0100 |
commit | 999e51572c093be901d6c8f942feb76038ae940c (patch) | |
tree | 0b2242d6df50748abf3f11c717211e8bbcf3d45e /files/de/web/javascript/reference/errors/deprecated_string_generics | |
parent | 747e709ad97c5782af29688f52c8105c08d9a323 (diff) | |
parent | 12b585b8e60a2877ff64dc6dc5ab058c43652f47 (diff) | |
download | translated-content-999e51572c093be901d6c8f942feb76038ae940c.tar.gz translated-content-999e51572c093be901d6c8f942feb76038ae940c.tar.bz2 translated-content-999e51572c093be901d6c8f942feb76038ae940c.zip |
Merge pull request #55 from fiji-flo/unslugging-de
Unslugging de
Diffstat (limited to 'files/de/web/javascript/reference/errors/deprecated_string_generics')
-rw-r--r-- | files/de/web/javascript/reference/errors/deprecated_string_generics/index.html | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/errors/deprecated_string_generics/index.html b/files/de/web/javascript/reference/errors/deprecated_string_generics/index.html new file mode 100644 index 0000000000..b41254150e --- /dev/null +++ b/files/de/web/javascript/reference/errors/deprecated_string_generics/index.html @@ -0,0 +1,105 @@ +--- +title: 'Warning: String.x is deprecated; use String.prototype.x instead' +slug: Web/JavaScript/Reference/Errors/Deprecated_String_generics +tags: + - JavaScript + - Warning +translation_of: Web/JavaScript/Reference/Errors/Deprecated_String_generics +original_slug: Web/JavaScript/Reference/Fehler/Deprecated_String_generics +--- +<div>{{jsSidebar("Errors")}}</div> + +<h2 id="Fehlermeldung">Fehlermeldung</h2> + +<pre class="syntaxbox">Warning: String.charAt is deprecated; use String.prototype.charAt instead +Warning: String.charCodeAt is deprecated; use String.prototype.charCodeAt instead +Warning: String.concat is deprecated; use String.prototype.concat instead +Warning: String.contains is deprecated; use String.prototype.contains instead +Warning: String.endsWith is deprecated; use String.prototype.endsWith instead +Warning: String.includes is deprecated; use String.prototype.includes instead +Warning: String.indexOf is deprecated; use String.prototype.indexOf instead +Warning: String.lastIndexOf is deprecated; use String.prototype.lastIndexOf instead +Warning: String.localeCompare is deprecated; use String.prototype.localeCompare instead +Warning: String.match is deprecated; use String.prototype.match instead +Warning: String.normalize is deprecated; use String.prototype.normalize instead +Warning: String.replace is deprecated; use String.prototype.replace instead +Warning: String.search is deprecated; use String.prototype.search instead +Warning: String.slice is deprecated; use String.prototype.slice instead +Warning: String.split is deprecated; use String.prototype.split instead +Warning: String.startsWith is deprecated; use String.prototype.startsWith instead +Warning: String.substr is deprecated; use String.prototype.substr instead +Warning: String.substring is deprecated; use String.prototype.substring instead +Warning: String.toLocaleLowerCase is deprecated; use String.prototype.toLocaleLowerCase instead +Warning: String.toLocaleUpperCase is deprecated; use String.prototype.toLocaleUpperCase instead +Warning: String.toLowerCase is deprecated; use String.prototype.toLowerCase instead +Warning: String.toUpperCase is deprecated; use String.prototype.toUpperCase instead +Warning: String.trim is deprecated; use String.prototype.trim instead +Warning: String.trimLeft is deprecated; use String.prototype.trimLeft instead +Warning: String.trimRight is deprecated; use String.prototype.trimRight instead +</pre> + +<h2 id="Fehlertyp">Fehlertyp</h2> + +<p>Warnung. JavaScript unterbricht die Ausführung nicht.</p> + +<h2 id="Was_ist_falsch_gelaufen">Was ist falsch gelaufen?</h2> + +<p>Die nicht standardisierten generischen {{jsxref("String")}} Methoden sind veraltet und werden in Zukunft gelöscht (keine Browserübergreifende Unterstützung, nur in Firefox verfügbar). <span id="result_box" lang="de"><span>String-Generics stellen String-Instanzmethoden für das String-Objekt bereit, wodurch String-Methoden auf jedes Objekt angewendet werden können.</span></span></p> + +<p>Firefox {{bug(1222552)}} dokumentiert das Entfernen von generischen String Methoden.</p> + +<h2 id="Beispiele">Beispiele</h2> + +<h3 id="Fehlerfälle">Fehlerfälle</h3> + +<pre class="brush: js example-bad">var num = 15; +String.replace(num, /5/, '2');</pre> + +<h3 id="Gültige_Fälle">Gültige Fälle</h3> + +<pre class="brush: js example-good">var num = 15; +String(num).replace(/5/, '2'); +</pre> + +<h2 id="Shim">Shim</h2> + +<p><span id="result_box" lang="de"><span>Das Folgende ist ein Shim zur Unterstützung nicht unterstützender Browser:</span></span></p> + +<pre class="brush: js">/*globals define*/ +// Assumes all supplied String instance methods already present +// (one may use shims for these if not available) +(function() { + 'use strict'; + + var i, + // We could also build the array of methods with the following, but the + // getOwnPropertyNames() method is non-shimable: + // Object.getOwnPropertyNames(String).filter(function(methodName) { + // return typeof String[methodName] === 'function'; + // }); + methods = [ + 'contains', 'substring', 'toLowerCase', 'toUpperCase', 'charAt', + 'charCodeAt', 'indexOf', 'lastIndexOf', 'startsWith', 'endsWith', + 'trim', 'trimLeft', 'trimRight', 'toLocaleLowerCase', 'normalize', + 'toLocaleUpperCase', 'localeCompare', 'match', 'search', 'slice', + 'replace', 'split', 'substr', 'concat', 'localeCompare' + ], + methodCount = methods.length, + assignStringGeneric = function(methodName) { + var method = String.prototype[methodName]; + String[methodName] = function(arg1) { + return method.apply(arg1, Array.prototype.slice.call(arguments, 1)); + }; + }; + + for (i = 0; i < methodCount; i++) { + assignStringGeneric(methods[i]); + } +}());</pre> + +<h2 id="Siehe_auch">Siehe auch</h2> + +<ul> + <li>{{jsxref("String")}}</li> + <li>Es gibt ebenfalls {{jsxref("Global_Objects/Array", "Generische Array Methoden", "#Array_generic_methods", 1)}} (die auch veraltet sind).</li> +</ul> |