aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/string/raw
diff options
context:
space:
mode:
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/string/raw')
-rw-r--r--files/de/web/javascript/reference/global_objects/string/raw/index.html160
1 files changed, 160 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/string/raw/index.html b/files/de/web/javascript/reference/global_objects/string/raw/index.html
new file mode 100644
index 0000000000..4405b1b72d
--- /dev/null
+++ b/files/de/web/javascript/reference/global_objects/string/raw/index.html
@@ -0,0 +1,160 @@
+---
+title: String.raw()
+slug: Web/JavaScript/Reference/Global_Objects/String/raw
+tags:
+ - ECMAScript 2015
+ - JavaScript
+ - Method
+ - Reference
+ - String
+translation_of: Web/JavaScript/Reference/Global_Objects/String/raw
+---
+<div>{{JSRef}}</div>
+
+<div>Die statische <strong><code>String.raw()</code></strong> Methode ist eine tag Funktion für <a href="/de/docs/Web/JavaScript/Reference/template_strings">template literale</a> ähnlich dem r Präfix in Python oder dem @ Präfix in C# für String Literale (es gibt jedoch einen Unterschied: siehe in der Beschreibung <a href="https://bugs.chromium.org/p/v8/issues/detail?id=5016">dieses Issues</a>). Es wird verwendet um rohen, unveränderten Text zu verwenden.</div>
+
+<div> </div>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox"><code>String.raw(<var>callSite</var>, <var>...substitutions</var>)
+String.raw`templateString`
+</code></pre>
+
+<h3 id="Parameter">Parameter</h3>
+
+<dl>
+ <dt><code>callSite</code></dt>
+ <dd>Sauber formatiertes template call object, wie <code>{ raw: 'string' }</code>.</dd>
+ <dt><code>...substitutions</code></dt>
+ <dd>Enthält Substitutionswerte.</dd>
+ <dt><code>templateString</code></dt>
+ <dd>Ein <a href="/de/docs/Web/JavaScript/Reference/template_strings">template string</a>, optional mit Substitutionen (<code>${...}</code>).</dd>
+</dl>
+
+<h3 id="Rückgabewerte">Rückgabewerte</h3>
+
+<p>Einen rohen, unveränderbaren String des template Strings.</p>
+
+<h3 id="Auftretende_Errors">Auftretende Errors</h3>
+
+<dl>
+ <dt>{{jsxref("TypeError")}}</dt>
+ <dd>Ein {{jsxref("TypeError")}}  wird ausgeworfen wenn das erste Argument nicht sauber formatiert ist.</dd>
+</dl>
+
+<h2 id="Beschreibung">Beschreibung</h2>
+
+<p>Meistens wird <code>String.raw()</code> mit template strings (Vorlagen-Zeichenketten) benutzt. Die erste oben beschriebene Syntax wird kaum benutzt weil die JavaScript engine die Argumente richtig aufrufen wird so wie bei anderen <a href="/de/docs/Web/JavaScript/Reference/template_strings#Tagged_template_strings">tag Funktionen.</a></p>
+
+<p><code>String.raw()</code> ist die einzige built-in tag function für template strings; Sie funktioniert wie eine default template function und führt concatenation (Verbindung mehrerer Strings zu einem) aus. Man kann sie sogar mit JS code neu schreiben.</p>
+
+<h2 id="Beispiele">Beispiele</h2>
+
+<h3 id="Verwendung_von_String.raw()">Verwendung von <code>String.raw()</code></h3>
+
+<pre class="brush: js">String.raw`Hi\n${2+3}!`;
+// 'Hi\\n5!', das Zeichen nach 'Hi' ist kein newline (Zeilenumbruch) Zeichen,
+// '\' und 'n' sind zwei Zeichen.
+
+String.raw`Hi\u000A!`;
+// 'Hi\\u000A!', hier genauso, diesmal bekommen wir folgende Zeichen zurrück:
+// \, u, 0, 0, 0, A, 6
+// Alle Typen von escape characters (besondere Steuerzeichen) sind ineffektiv
+// Backslashes werden unverändert ausgegeben.
+// Man kann dies prüfen indem man die .length property des strings abfragt
+console.log( String.raw`Hi\u000A!`.length ) // gibt 9 zurrück
+console.log( "Hi\u000A!".length ) // gibt 4 zurrück
+
+
+let name = 'Bob';
+String.raw`Hi\n${name}!`;
+// 'Hi\\nBob!', Substitutionen werden bearbeitet.
+
+// Normalerweise ruft man String.raw() nicht als function auf aber man kann
+//folgendes:
+String.raw({ raw: 'test' }, 0, 1, 2);
+// 't0e1s2t'
+</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-string.raw', 'String.raw')}}</td>
+ <td>{{Spec2('ES2015')}}</td>
+ <td>Initiale Definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-string.raw', 'String.raw')}}</td>
+ <td>{{Spec2('ESDraft')}}</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>41</td>
+ <td>{{CompatGeckoDesktop("34")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</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>{{CompatNo}}</td>
+ <td>41</td>
+ <td>{{CompatGeckoMobile("34")}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ <td>{{CompatNo}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/de/docs/Web/JavaScript/Reference/template_strings">Template strings</a></li>
+ <li>{{jsxref("String")}}</li>
+ <li><a href="/de/docs/Web/JavaScript/Reference/Lexical_grammar">Lexical grammar</a></li>
+</ul>