aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/guide/ausdruecke_und_operatoren
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
commit4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch)
treed4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/de/web/javascript/guide/ausdruecke_und_operatoren
parent33058f2b292b3a581333bdfb21b8f671898c5060 (diff)
downloadtranslated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip
initial commit
Diffstat (limited to 'files/de/web/javascript/guide/ausdruecke_und_operatoren')
-rw-r--r--files/de/web/javascript/guide/ausdruecke_und_operatoren/index.html965
1 files changed, 965 insertions, 0 deletions
diff --git a/files/de/web/javascript/guide/ausdruecke_und_operatoren/index.html b/files/de/web/javascript/guide/ausdruecke_und_operatoren/index.html
new file mode 100644
index 0000000000..7a0e723c6c
--- /dev/null
+++ b/files/de/web/javascript/guide/ausdruecke_und_operatoren/index.html
@@ -0,0 +1,965 @@
+---
+title: Ausdrücke und Operatoren
+slug: Web/JavaScript/Guide/Ausdruecke_und_Operatoren
+tags:
+ - Beginner
+ - Extensions
+ - Guide
+ - JavaScript
+ - Operatoren
+ - 'l10n:priority'
+translation_of: Web/JavaScript/Guide/Expressions_and_Operators
+---
+<div>{{jsSidebar("JavaScript Guide")}} {{PreviousNext("Web/JavaScript/Guide/Funktionen", "Web/JavaScript/Guide/Numbers_and_dates")}}</div>
+
+<p class="summary">Dieses Kapitel beschreibt JavaScript Ausdrücke und Operatoren, Zuweisungsoperatoren, Vergleichsoperatoren, Rechenoperatoren, Bit-Operatoren, Logische Operatoren, Operator zur Zeichenkettenverknüpfung, Bedingte (ternäre) Operatoren und mehr.</p>
+
+<p>Eine vollständige und detaillierte Liste mit Operatoren und Ausdrücken ist in den <a href="/de-DE/docs/Web/JavaScript/Reference/Operators">Referenzen</a> zu finden.</p>
+
+<h2 id="Operatoren">Operatoren</h2>
+
+<p>JavaScript besitzt verschiedene Operatortypen. Dieser Abschnitt beschreibt die einzelnen Operatoren und beinhaltet Informationen über die Operator-Prioritäten.</p>
+
+<ul>
+ <li>{{ web.link("#Assignment_operators", "Zuweisungs-Operatoren") }}</li>
+ <li>{{ web.link("#Comparison_operators", "Vergleichs-Operatoren") }}</li>
+ <li>{{ web.link("#Arithmetic_operators", "Arithmetische Operatoren") }}</li>
+ <li>{{ web.link("#Bitwise_operators", "Bit-Operatoren") }}</li>
+ <li>{{ web.link("#Logical_operators", "Logische Operatoren") }}</li>
+ <li>{{ web.link("#String_operators", "String Operatoren") }}</li>
+ <li>{{ web.link("#Conditional_(ternary)_operator", "Bedingter (ternärer) Operator")}}</li>
+ <li>{{ web.link("#Comma_operator", "Komma Operator")}}</li>
+ <li>{{ web.link("#Unary_operators", "Unäre Operatoren")}}</li>
+ <li>{{ web.link("#Relational_operators", "Vergleichsoperator")}}</li>
+</ul>
+
+<p>JavaScript verfügt über beides, binäre als auch unäre Operatoren. Zudem existiert ein spezieller ternärer Operator - der Bedingungsoperator. Ein binärer Operator benötigt zwei Operanden, einen vor dem Operator und einen nach dem Operator:</p>
+
+<pre class="syntaxbox"><em>operand1</em> <em>operator</em> <em>operand2</em>
+</pre>
+
+<p>Zum Beispiel: <code>3+4</code>, oder <code>x*y</code>.</p>
+
+<p>Ein unärer Operator erwartet einen einzelnen Operanden, entweder vor, oder nach dem Operator:</p>
+
+<pre class="syntaxbox"><em>operator</em> <em>operand</em>
+</pre>
+
+<p>oder</p>
+
+<pre class="syntaxbox"><em>operand</em> <em>operator</em>
+</pre>
+
+<p>Zum Beispiel: <code>x++</code>, oder <code>++x</code>.</p>
+
+<h3 id="Zuweisungsoperatoren">Zuweisungsoperatoren</h3>
+
+<p>Ein Zuweisungsoperator weißt seinem linken Operanden einen Wert zu. Dieser Wert basiert auf dem Ergebnis des rechten Operanden. Der einfachste Zuweisungsoperator ist das "Gleich" (<code>=</code>), welches den Wert des rechten Operanden dem linken Operanden zuweist.</p>
+
+<p>Zum Beispiel: <code>x = y</code> (<code>y</code> wid der Wert von <code>x</code> zugewiesen).</p>
+
+<p>Es gibt auch zusammengesetzte Zuweisungsoperatoren, diese stellen Abkürzungen für die in der folgenden Tabelle aufgelisteten Operationen dar:</p>
+
+<table class="standard-table">
+ <caption>Zusammengesetzte Zuweisungsoperatoren</caption>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Abgekürzter Operator</th>
+ <th>Ausgeschriebener Operator</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Assignment" title="Zuweisung">Zuweisung</a></td>
+ <td><code>x = y</code></td>
+ <td><code>x = y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Addition_assignment">Addition</a></td>
+ <td><code>x += y</code></td>
+ <td><code>x = x + y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Subtraction_assignment">Subraktion</a></td>
+ <td><code>x -= y</code></td>
+ <td><code>x = x - y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Multiplication_assignment">Multiplikation</a></td>
+ <td><code>x *= y</code></td>
+ <td><code>x = x * y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Division_assignment">Division</a></td>
+ <td><code>x /= y</code></td>
+ <td><code>x = x / y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Remainder_assignment">Modulo (Division mit Rest)</a></td>
+ <td><code>x %= y</code></td>
+ <td><code>x = x % y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Exponentiation_assignment">Exponentiation assignment</a> {{experimental_inline}}</td>
+ <td><code>x **= y</code></td>
+ <td><code>x = x ** y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Left_shift_assignment">Left shift assignment</a></td>
+ <td><code>x &lt;&lt;= y</code></td>
+ <td><code>x = x &lt;&lt; y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Right_shift_assignment">Right shift assignment</a></td>
+ <td><code>x &gt;&gt;= y</code></td>
+ <td><code>x = x &gt;&gt; y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Unsigned_right_shift_assignment">Unsigned right shift assignment</a></td>
+ <td><code>x &gt;&gt;&gt;= y</code></td>
+ <td><code>x = x &gt;&gt;&gt; y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_AND_assignment">Bitwise AND assignment</a></td>
+ <td><code>x &amp;= y</code></td>
+ <td><code>x = x &amp; y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_XOR_assignment">Bitwise XOR assignment</a></td>
+ <td><code>x ^= y</code></td>
+ <td><code>x = x ^ y</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators#Bitwise_OR_assignment">Bitwise OR assignment</a></td>
+ <td><code>x |= y</code></td>
+ <td><code>x = x | y</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Destrukturierung">Destrukturierung</h4>
+
+<p>Komplexere Zuweisungen ermöglicht Javascript über die sogenannte <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment">Destrukturierung</a>. Diese ermöglicht es, Daten aus Arrays oder Objekten mithilfe einer Syntax zu extrahieren, die die Konstruktion von Array- und Objektliteralen widerspiegelt.</p>
+
+<pre class="brush: js">var foo = ["eins", "zwei", "drei"];
+
+// Ohne Destrukturierung
+var eins = foo[0];
+var zwei = foo[1];
+var drei = foo[2];
+
+// mit Destrukturierung
+var [eins, zwei, drei] = foo;</pre>
+
+<h3 id="Vergleichsoperatoren">Vergleichsoperatoren</h3>
+
+<p>Ein Vergleichsoperator vergleicht seine Operanden und gibt einen logischen Wert zurück, der darauf basiert, ob der Vergleich wahr ist, oder nicht.</p>
+
+<p>Die Operanden können numerische-, string-, logische- oder Objektwerte sein. Zeichenfolgen werden basierend auf der lexikographischen Standardreihenfolge mit unicodewerten verglichen. Wenn die beiden Operanden nicht vom selben Typ sind, versucht JavaScript in den meisten Fällen, sie in einen geeigneten Typ für den Vergleich zu konvertieren. Dieses Verhalten führt im Allgemeinen dazu, dass die Operanden numerisch verglichen werden. Die einzigen Ausnahmen für die Typumwandlung innerhalb von Vergleichen sind die Operatoren <code>===</code> und <code>!==</code>, die strenge Vergleiche durchführen. Diese Operatoren versuchen nicht, die Operanden in kompatible Typen zu konvertieren, bevor sie die Gleichheit überprüfen.</p>
+
+<p>Die folgende Tabelle beschreibt die Vergleichsoperatoren in Bezug auf diesen Beispielcode:</p>
+
+<pre class="brush: js">var var1 = 3;
+var var2 = 4;
+</pre>
+
+<table class="standard-table">
+ <caption>Vergleichsoperatoren</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator</th>
+ <th scope="col">Beschreibung</th>
+ <th scope="col">Beispiele, die <code>true</code> zurückgeben</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality">Equal</a> (<code>==</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn die Operanden gleich sind.</td>
+ <td><code>3 == var1</code>
+ <p><code>"3" == var1</code></p>
+ <code>3 == '3'</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality">Not equal</a> (<code>!=</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn die Operanden ungleich sind.</td>
+ <td><code>var1 != 4<br>
+ var2 != "3"</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity">Strict equal</a> (<code>===</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn die Operanden gleich sind und auch der Typ übereinstimmt. Weitere Informationen unter {{jsxref("Object.is")}} und <a href="/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness" title="/en-US/docs/Web/JavaScript/Guide/Sameness">sameness in JS</a>.</td>
+ <td><code>3 === var1</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity">Strict not equal</a> (<code>!==</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn die Operanden vom selben Typ sind, doch nicht den selben Wert haben, oder wenn sie den selben Wert haben, doch nicht vom selben Typ sind.</td>
+ <td><code>var1 !== "3"<br>
+ 3 !== '3'</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator">Greater than</a> (<code>&gt;</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn der linke Operand größer dem rechten Operanden ist.</td>
+ <td><code>var2 &gt; var1<br>
+ "12" &gt; 2</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator">Greater than or equal</a> (<code>&gt;=</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn der linke Operand größer als, oder gleich dem linken Operanden ist.</td>
+ <td><code>var2 &gt;= var1<br>
+ var1 &gt;= 3</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator">Less than</a> (<code>&lt;</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn der linke Operand kleiner dem rechten Operanden ist.</td>
+ <td><code>var1 &lt; var2<br>
+ "2" &lt; 12</code></td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_or_equal_operator">Less than or equal</a> (<code>&lt;=</code>)</td>
+ <td>Gibt <code>true</code> zurück, wenn der linke Operand kleiner als, oder gleich dem rechten Operanden ist.</td>
+ <td><code>var1 &lt;= var2<br>
+ var2 &lt;= 5</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="note">
+<p><strong>Note: </strong>(<strong>=&gt;</strong>) ist kein Operator, hiermit werden <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions">Arrow functions</a> notiert.</p>
+</div>
+
+<h3 id="Arithmetische_Operatoren_(Rechenzeichen)">Arithmetische Operatoren (Rechenzeichen)</h3>
+
+<p>Ein <a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators">arithmetischer Operator</a> nimmt numerische Werte (Literale oder Variablen) als Operanden entgegen und gibt einen einzelnen numerischen Wert zurück. Die arithmetischen Standardoperatoren sind Addition (<code>+)</code>, Subtraktion (<code>-</code>), Multiplikation (<code>*</code>) und Division (<code>/</code>). Diese Operatoren funktionieren wie in den meisten anderen Programmiersprachen, wenn sie mit Fließkommazahlen verwendet werden (beachten Sie insbesondere, dass die Division durch Null {{jsxref ("Infinity")}} ergibt).</p>
+
+<pre class="brush: js">1 / 2; // 0.5
+1 / 2 == 1.0 / 2.0; // this is true
+</pre>
+
+<p>Neben den arithmetischen Standardoperatoren (+, -, * /), stellt JavaScript noch weitere Rechenzeichen zur Verfügung. Diese werden in der folgenden Tabelle aufgeführt:</p>
+
+<table class="fullwidth-table">
+ <caption>Arithmetische Operatoren</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator</th>
+ <th scope="col">Beschreibung</th>
+ <th scope="col">Beispiel</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder">Remainder</a> (<code>%</code>)</td>
+ <td>Binärer Operator. Gibt den ganzzahligen Rest der Division beider Operanden zurück.</td>
+ <td><code>12 % 5</code> gibt <code>2</code> zurück.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment">Increment</a> (<code>++</code>)</td>
+ <td>
+ <p>Unärer Operator. Addiert 1 zu seinem Operanden.</p>
+
+ <p>Wenn der Operator vorangestellt wird (<code>++x</code>), gibt er den Wert seines Operanden zurück nachdem 1 addiert wurde; Wenn der Operator nachgestellt wird (<code>x++</code>), gibt er den Wert seines Operanden zurück, bevor 1 addiert wurde.</p>
+ </td>
+ <td>Wenn <code>x</code> gleich 3 ist, setzt <code>++x</code> <code>x</code> auf 4 und gibt 4 zurück, wobei <code>x++</code>  3 zurückgibt und erst danach <code>x</code> auf 4 setzt.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement">Decrement</a> (<code>--</code>)</td>
+ <td>
+ <p>Unärer Operator. Subtrahiert 1 von seinem Operanden.</p>
+
+ <p>Der Rückgabewert verhält sich analog zum increment Operator.</p>
+ </td>
+ <td>Wenn <code>x</code> gleich 3 ist, setzt <code>--x</code> <code>x</code> auf 2 und gibt 2 zurück, wobei <code>x--</code> 3 zurückgibt und erst danach, <code>x</code> auf 2 setzt.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation">Unary negation</a> (<code>-</code>)</td>
+ <td>Unärer Operator. Gibt die Negierung seines Operanden zurück.</td>
+ <td>Wenn <code>x</code> gleich 3 ist, gibt <code>-x</code> -3 zurück.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus">Unary plus</a> (<code>+</code>)</td>
+ <td>Versucht, den Operanden in eine Zahl umzuwandeln, wenn dies nicht bereits der Fall ist.</td>
+ <td><code>+"3"</code> gibt <code>3</code> zurück.<br>
+ <code>+true</code> gibt <code>1</code> zurück.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation">Exponentiation operator</a> (<code>**</code>) {{experimental_inline}}</td>
+ <td>Calculates the <code>base</code> to the <code>exponent</code> power, that is, <code>base<sup>exponent</sup></code></td>
+ <td><code>2 ** 3</code> gibt <code>8</code> zurück.<br>
+ <code>10 ** -1</code> gibt <code>0.1 </code>zurück.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Bitweise_Operatoren">Bitweise Operatoren</h3>
+
+<p>Ein bitweiser Operator behandelt seine Operanden als eine Menge von 32 Bits (Nullen und Einsen) und nicht als dezimale, hexadezimale oder oktale Zahlen. Zum Beispiel hat die Dezimalzahl Neun eine binäre Darstellung von <code>1001</code>. Bitweise Operatoren führen ihre Operationen mit solchen binären Darstellungen aus, doch sie geben standardmäßige numerische JavaScript-Werte zurück.</p>
+
+<p>Die folgende Tabelle fasst die bitweisen Operatoren von JavaScript zusammen.</p>
+
+<table class="standard-table">
+ <caption>Bitweise Operatoren</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator</th>
+ <th scope="col">Verwendung</th>
+ <th scope="col">Beschreibung</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND">Bitwise AND</a></td>
+ <td><code>a &amp; b</code></td>
+ <td>Returns a one in each bit position for which the corresponding bits of both operands are ones.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR">Bitwise OR</a></td>
+ <td><code>a | b</code></td>
+ <td>Returns a zero in each bit position for which the corresponding bits of both operands are zeros.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR">Bitwise XOR</a></td>
+ <td><code>a ^ b</code></td>
+ <td>Returns a zero in each bit position for which the corresponding bits are the same.<br>
+ [Returns a one in each bit position for which the corresponding bits are different.]</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT">Bitwise NOT</a></td>
+ <td><code>~ a</code></td>
+ <td>Inverts the bits of its operand.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Left_shift">Left shift</a></td>
+ <td><code>a &lt;&lt; b</code></td>
+ <td>Shifts <code>a</code> in binary representation <code>b</code> bits to the left, shifting in zeros from the right.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Right_shift">Sign-propagating right shift</a></td>
+ <td><code>a &gt;&gt; b</code></td>
+ <td>Shifts <code>a</code> in binary representation <code>b</code> bits to the right, discarding bits shifted off.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Unsigned_right_shift">Zero-fill right shift</a></td>
+ <td><code>a &gt;&gt;&gt; b</code></td>
+ <td>Shifts <code>a</code> in binary representation <code>b</code> bits to the right, discarding bits shifted off, and shifting in zeros from the left.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h4 id="Bitwise_Logical_Operators" name="Bitwise_Logical_Operators">Bitweise logische Operatoren</h4>
+
+<p>Konzeptuell arbeiten bitweise logische Operatoren wie folgt:</p>
+
+<ul>
+ <li>Die Operanden werden zu 32 Bit Integer Zahlen konvertiert und als Folge von Bits (Nullen und Einsen) dargestellt. Zahlen mit mehr als 32 Bits verlieren dabei ihre signifikanten Bits bis auf eine Länge von 32. Im folgenden Beispiel wird eine Zahl mit mehr als 32 Bits zu einer 32 Bit Integer Zahl konvertiert:
+ <pre>Before: 11100110111110100000000000000110000000000001
+After: 10100000000000000110000000000001</pre>
+ </li>
+ <li>Jedes Bit des ersten Operanden wird mit dem korrespondierenden Bit im zweiten Operanden gepaart: Erstes Bit mit dem ersten Bit, zweites Bit mit dem zweiten Bit und so weiter.</li>
+ <li>Der Operator wird auf jedes paar von Bits angewendet und das Ergebnis bitweise erstellt.</li>
+</ul>
+
+<p>Zum Beispiel ist die binäre Darstellung der Zahl neun 1001, die binäre Darstellung der Zahl 15 ist 1111. Wenn die bitweisen logischen Operatoren auf diese Zahlen angewendet werden, ergeben sich folgende Ergebnisse:</p>
+
+<table class="standard-table">
+ <caption>Beispiele für bitweise Operatoren</caption>
+ <thead>
+ <tr>
+ <th scope="col">Ausdruck</th>
+ <th scope="col">Ergebnis</th>
+ <th scope="col">Binäre Darstellung</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>15 &amp; 9</code></td>
+ <td><code>9</code></td>
+ <td><code>1111 &amp; 1001 = 1001</code></td>
+ </tr>
+ <tr>
+ <td><code>15 | 9</code></td>
+ <td><code>15</code></td>
+ <td><code>1111 | 1001 = 1111</code></td>
+ </tr>
+ <tr>
+ <td><code>15 ^ 9</code></td>
+ <td><code>6</code></td>
+ <td><code>1111 ^ 1001 = 0110</code></td>
+ </tr>
+ <tr>
+ <td><code>~15</code></td>
+ <td><code>-16</code></td>
+ <td><code>~</code><code>00000000...</code><code>00001111 = </code><code>1111</code><code>1111</code><code>...</code><code>11110000</code></td>
+ </tr>
+ <tr>
+ <td><code>~9</code></td>
+ <td><code>-10</code></td>
+ <td><code>~</code><code>00000000</code><code>...</code><code>0000</code><code>1001 = </code><code>1111</code><code>1111</code><code>...</code><code>1111</code><code>0110</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Beachte, dass alle 32 Bits invertiert werden, wenn der bitweise NOT Operator benutzt wird. Wenn dabei das höchstwertigste (ganz linke) Bit auf 1 gesetzt wird, entsteht eine negative Zahl. Note that all 32 bits are inverted using the Bitwise NOT operator, and that values with the most significant (left-most) bit set to 1 represent negative numbers (Zweierkomplement). <code>~x</code> wird also genauso ausgewertet wie <code>-x - 1</code>.</p>
+
+<h4 id="Bitwise_Shift_Operators" name="Bitwise_Shift_Operators">Bitweise Schiebeoperatoren</h4>
+
+<p>Die bitweisen Schiebeoperatoren erwarten zwei Operanden. Der erste ist der Wert, der geschoben werden soll, der zweite die Anzahl der Bits, um die geschoben werden soll. Die Richtung, in die geschoben wird, wird durch den verwendeten Operator bestimmt.</p>
+
+<p>Schiebeoperatoren konvertieren ihre Operanden in 32 Bit Integer Zahlen und liefern als Ergebnis einen Wert vom selben Typen wir der linke Operand.</p>
+
+<p>Die Schiebeoperatoren sind in der folgenden Tabelle aufgelistet.</p>
+
+<table class="fullwidth-table">
+ <caption>Bitwise shift operators</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator</th>
+ <th scope="col">Description</th>
+ <th scope="col">Example</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#&lt;&lt;_(Left_shift)">Left shift</a><br>
+ (<code>&lt;&lt;</code>)</td>
+ <td>This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded. Zero bits are shifted in from the right.</td>
+ <td><code>9&lt;&lt;2</code> yields 36, because 1001 shifted 2 bits to the left becomes 100100, which is 36.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#>>_(Sign-propagating_right_shift)">Sign-propagating right shift</a> (<code>&gt;&gt;</code>)</td>
+ <td>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Copies of the leftmost bit are shifted in from the left.</td>
+ <td><code>9&gt;&gt;2</code> yields 2, because 1001 shifted 2 bits to the right becomes 10, which is 2. Likewise, <code>-9&gt;&gt;2</code> yields -3, because the sign is preserved.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#>>>_(Zero-fill_right_shift)">Zero-fill right shift</a> (<code>&gt;&gt;&gt;</code>)</td>
+ <td>This operator shifts the first operand the specified number of bits to the right. Excess bits shifted off to the right are discarded. Zero bits are shifted in from the left.</td>
+ <td><code>19&gt;&gt;&gt;2</code> yields 4, because 10011 shifted 2 bits to the right becomes 100, which is 4. For non-negative numbers, zero-fill right shift and sign-propagating right shift yield the same result.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h3 id="Logische_Operatoren">Logische Operatoren</h3>
+
+<p><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators">Logische Operatoren</a> werden normalerweise mit boolesche (logischen) Werten verwendet - hierbei geben sie dann einen booleschen Wert zurück. Die Operatoren <code>&amp;&amp;</code> und <code>||</code> geben den Wert von einem der Operatoren zurück, sodass sie im Falle der Verwendung mit einem nicht-booleschen Wert auch einen nicht-booleschen Wert zurückgeben können. Die logischen Operatoren werden in der folgenden Tabelle beschrieben: </p>
+
+<table class="fullwidth-table">
+ <caption>Logische Operatoren</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator</th>
+ <th scope="col">Verwendung</th>
+ <th scope="col">Beschreibung</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND">Logical AND</a><code> </code>(<code>&amp;&amp;</code>)</td>
+ <td><code>expr1 &amp;&amp; expr2</code></td>
+ <td>Gibt <code>expr1</code> zurück, sofern es zu <code>false</code> konvertiert werden kann; ansonsten wird <code>expr2</code> zurückgegeben. Insofern mit booleschen Werten verwendet, <code>&amp;&amp;</code> gibt <code>true</code> zurück, wenn beide Operanden wahr sind; ansonsten <code>false</code>.</td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR">Logical OR </a>(<code>||</code>)</td>
+ <td><code>expr1 || expr2</code></td>
+ <td>
+ <p>Gibt <code>expr1</code> zurück, sofern er zu <code>true</code> konvertiert werden kann. Insofern mit booleschen Werten verwendet, gibt der Operator <code>||</code> true zurück, wenn einer von beiden Operanden <code>true</code> ist; wenn beide <code>false</code> sind, wird <code>false</code> zurückgegeben. </p>
+ </td>
+ </tr>
+ <tr>
+ <td><a href="/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT">Logical NOT </a>(<code>!</code>)</td>
+ <td><code>!expr</code></td>
+ <td>
+ <p>Gibt <code>false</code> zurück, wenn sein einziger Operand in <code>true</code> konvertiert werden kann; andernfalls gibt er <code>true</code> zurück. </p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Beispiele von Ausdrücken, die in <code>false</code> umgewandelt werden können, sind solche, die <code>null</code>, 0, <code>NaN</code>, einen leeren String ("") oder <code>undefined</code> sind. </p>
+
+<p>Die folgenden Zeilen zeigen Beispiele des <code>&amp;&amp;</code> (logisches UND) Operators.</p>
+
+<pre class="brush: js">var a1 = true &amp;&amp; true; // t &amp;&amp; t returns true
+var a2 = true &amp;&amp; false; // t &amp;&amp; f returns false
+var a3 = false &amp;&amp; true; // f &amp;&amp; t returns false
+var a4 = false &amp;&amp; (3 == 4); // f &amp;&amp; f returns false
+var a5 = "Cat" &amp;&amp; "Dog"; // t &amp;&amp; t returns Dog
+var a6 = false &amp;&amp; "Cat"; // f &amp;&amp; t returns false
+var a7 = "Cat" &amp;&amp; false; // t &amp;&amp; f returns false
+</pre>
+
+<p>Die folgenden Zeilen zeigen Beispiele des <code>||</code> (logisches ODER) Operators:</p>
+
+<pre class="brush: js">var o1 = true || true; // t || t returns true
+var o2 = false || true; // f || t returns true
+var o3 = true || false; // t || f returns true
+var o4 = false || (3 == 4); // f || f returns false
+var o5 = "Cat" || "Dog"; // t || t returns Cat
+var o6 = false || "Cat"; // f || t returns Cat
+var o7 = "Cat" || false; // t || f returns Cat
+</pre>
+
+<p>Die folgenden Zeilen zeigen Beispiele des <code>!</code> (logisches NICHT) Operators:</p>
+
+<pre class="brush: js">var n1 = !true; // !t returns false
+var n2 = !false; // !f returns true
+var n3 = !"Cat"; // !t returns false
+</pre>
+
+<h4 id="Short-Circuit_Evaluation" name="Short-Circuit_Evaluation">Short-circuit-Bewertung </h4>
+
+<p>Da logische Ausdrücke von links nach rechts bewertet werden, werden sie auf eine mögliche "Abkürzung" (short-circuit) hin gemäß den folgenden Regeln evaluiert:</p>
+
+<ul>
+ <li><code>false</code> &amp;&amp; <em>irgendwas</em> wird abgekürzt als <code>false</code> bewertet.</li>
+ <li><code>true</code> || <em>irgendwas</em> wird abgekürtz als <code>true</code> bewertet. </li>
+</ul>
+
+<p>Die Regeln der Logik garantieren, dass diese Bewertungen immer korrekt sind. Der <em>irgendwas</em>-Operand werden in den o.g. Beispielen hierbei nicht bewertet. </p>
+
+<h3 id="String-Operatoren">String-Operatoren</h3>
+
+<p>In addition to the comparison operators, which can be used on string values, the concatenation operator (+) concatenates two string values together, returning another string that is the union of the two operand strings.</p>
+
+<p>For example,</p>
+
+<pre class="brush: js">console.log("my " + "string"); // console logs the string "my string".</pre>
+
+<p>The shorthand assignment operator += can also be used to concatenate strings.</p>
+
+<p>For example,</p>
+
+<pre class="brush: js">var mystring = "alpha";
+mystring += "bet"; // evaluates to "alphabet" and assigns this value to mystring.</pre>
+
+<h3 id="Conditional_(ternary)_operator">Conditional (ternary) operator</h3>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator">conditional operator</a> is the only JavaScript operator that takes three operands. The operator can have one of two values based on a condition. The syntax is:</p>
+
+<pre class="syntaxbox"><em>condition</em> ? <em>val1</em> : <em>val2</em>
+</pre>
+
+<p>If <code>condition</code> is true, the operator has the value of <code>val1</code>. Otherwise it has the value of <code>val2</code>. You can use the conditional operator anywhere you would use a standard operator.</p>
+
+<p>For example,</p>
+
+<pre class="brush: js">var status = (age &gt;= 18) ? "adult" : "minor";
+</pre>
+
+<p>This statement assigns the value "adult" to the variable <code>status</code> if <code>age</code> is eighteen or more. Otherwise, it assigns the value "minor" to <code>status</code>.</p>
+
+<h3 id="Comma_operator" name="Comma_operator">Comma operator</h3>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator">comma operator</a> (<code>,</code>) simply evaluates both of its operands and returns the value of the last operand. This operator is primarily used inside a <code>for</code> loop, to allow multiple variables to be updated each time through the loop.</p>
+
+<p>For example, if <code>a</code> is a 2-dimensional array with 10 elements on a side, the following code uses the comma operator to update two variables at once. The code prints the values of the diagonal elements in the array:</p>
+
+<pre class="brush: js">var x = [0,1,2,3,4,5,6,7,8,9];
+var a = [x, x, x, x, x]
+
+for (var i = 0, j = 9; i &lt;= j; i++, j--)
+ console.log("a[" + i + "][" + j + "]= " + a[i][j]);
+</pre>
+
+<h3 id="Unary_operators">Unary operators</h3>
+
+<p>A unary operation is an operation with only one operand.</p>
+
+<h4 id="delete" name="delete"><code>delete</code></h4>
+
+<p>The <code><a href="/en-US/docs/Web/JavaScript/Reference/Operators/delete">delete</a></code> operator deletes an object, an object's property, or an element at a specified index in an array. The syntax is:</p>
+
+<pre class="brush: js">delete objectName;
+delete objectName.property;
+delete objectName[index];
+delete property; // legal only within a with statement
+</pre>
+
+<p>where <code>objectName</code> is the name of an object, <code>property</code> is an existing property, and <code>index</code> is an integer representing the location of an element in an array.</p>
+
+<p>The fourth form is legal only within a <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/with">with</a></code> statement, to delete a property from an object.</p>
+
+<p>You can use the <code>delete</code> operator to delete variables declared implicitly but not those declared with the <code>var</code> statement.</p>
+
+<p>If the <code>delete</code> operator succeeds, it sets the property or element to <code>undefined</code>. The <code>delete</code> operator returns true if the operation is possible; it returns <code>false</code> if the operation is not possible.</p>
+
+<pre class="brush: js">x = 42;
+var y = 43;
+myobj = new Number();
+myobj.h = 4; // create property h
+delete x; // returns true (can delete if declared implicitly)
+delete y; // returns false (cannot delete if declared with var)
+delete Math.PI; // returns false (cannot delete predefined properties)
+delete myobj.h; // returns true (can delete user-defined properties)
+delete myobj; // returns true (can delete if declared implicitly)
+</pre>
+
+<h5 id="Deleting_array_elements">Deleting array elements</h5>
+
+<p>When you delete an array element, the array length is not affected. For example, if you delete <code>a[3]</code>, <code>a[4]</code> is still <code>a[4]</code> and <code>a[3]</code> is undefined.</p>
+
+<p>When the <code>delete</code> operator removes an array element, that element is no longer in the array. In the following example, <code>trees[3]</code> is removed with <code>delete</code>. However, <code>trees[3]</code> is still addressable and returns <code>undefined</code>.</p>
+
+<pre class="brush: js">var trees = ["redwood", "bay", "cedar", "oak", "maple"];
+delete trees[3];
+if (3 in trees) {
+ // this does not get executed
+}
+</pre>
+
+<p>If you want an array element to exist but have an undefined value, use the <code>undefined</code> keyword instead of the <code>delete</code> operator. In the following example, <code>trees[3]</code> is assigned the value <code>undefined</code>, but the array element still exists:</p>
+
+<pre class="brush: js">var trees = ["redwood", "bay", "cedar", "oak", "maple"];
+trees[3] = undefined;
+if (3 in trees) {
+ // this gets executed
+}
+</pre>
+
+<h4 id="typeof" name="typeof"><code>typeof</code></h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/typeof"><code>typeof</code> operator</a> is used in either of the following ways:</p>
+
+<pre class="syntaxbox">typeof operand
+typeof (operand)
+</pre>
+
+<p>The <code>typeof</code> operator returns a string indicating the type of the unevaluated operand. <code>operand</code> is the string, variable, keyword, or object for which the type is to be returned. The parentheses are optional.</p>
+
+<p>Suppose you define the following variables:</p>
+
+<pre class="brush: js">var myFun = new Function("5 + 2");
+var shape = "round";
+var size = 1;
+var today = new Date();
+</pre>
+
+<p>The <code>typeof</code> operator returns the following results for these variables:</p>
+
+<pre class="brush: js">typeof myFun; // returns "function"
+typeof shape; // returns "string"
+typeof size; // returns "number"
+typeof today; // returns "object"
+typeof dontExist; // returns "undefined"
+</pre>
+
+<p>For the keywords <code>true</code> and <code>null</code>, the <code>typeof</code> operator returns the following results:</p>
+
+<pre class="brush: js">typeof true; // returns "boolean"
+typeof null; // returns "object"
+</pre>
+
+<p>For a number or string, the <code>typeof</code> operator returns the following results:</p>
+
+<pre class="brush: js">typeof 62; // returns "number"
+typeof 'Hello world'; // returns "string"
+</pre>
+
+<p>For property values, the <code>typeof</code> operator returns the type of value the property contains:</p>
+
+<pre class="brush: js">typeof document.lastModified; // returns "string"
+typeof window.length; // returns "number"
+typeof Math.LN2; // returns "number"
+</pre>
+
+<p>For methods and functions, the <code>typeof</code> operator returns results as follows:</p>
+
+<pre class="brush: js">typeof blur; // returns "function"
+typeof eval; // returns "function"
+typeof parseInt; // returns "function"
+typeof shape.split; // returns "function"
+</pre>
+
+<p>For predefined objects, the <code>typeof</code> operator returns results as follows:</p>
+
+<pre class="brush: js">typeof Date; // returns "function"
+typeof Function; // returns "function"
+typeof Math; // returns "object"
+typeof Option; // returns "function"
+typeof String; // returns "function"
+</pre>
+
+<h4 id="void" name="void"><code>void</code></h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/void"><code>void</code> operator</a> is used in either of the following ways:</p>
+
+<pre class="syntaxbox">void (expression)
+void expression
+</pre>
+
+<p>The <code>void</code> operator specifies an expression to be evaluated without returning a value. <code>expression</code> is a JavaScript expression to evaluate. The parentheses surrounding the expression are optional, but it is good style to use them.</p>
+
+<p>You can use the <code>void</code> operator to specify an expression as a hypertext link. The expression is evaluated but is not loaded in place of the current document.</p>
+
+<p>The following code creates a hypertext link that does nothing when the user clicks it. When the user clicks the link, <code>void(0)</code> evaluates to <code>undefined</code>, which has no effect in JavaScript.</p>
+
+<pre class="brush: html"><a>Click here to do nothing</a>
+</pre>
+
+<p>The following code creates a hypertext link that submits a form when the user clicks it.</p>
+
+<pre class="brush: html"><a>
+Click here to submit</a></pre>
+
+<h3 id="Relational_operators">Relational operators</h3>
+
+<p>A relational operator compares its operands and returns a <code>Boolean</code> value based on whether the comparison is true.</p>
+
+<h4 id="in"><code>in</code></h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/in"><code>in</code> operator</a> returns true if the specified property is in the specified object. The syntax is:</p>
+
+<pre class="brush: js">propNameOrNumber in objectName
+</pre>
+
+<p>where <code>propNameOrNumber</code> is a string or numeric expression representing a property name or array index, and <code>objectName</code> is the name of an object.</p>
+
+<p>The following examples show some uses of the <code>in</code> operator.</p>
+
+<pre class="brush: js">// Arrays
+var trees = ["redwood", "bay", "cedar", "oak", "maple"];
+0 in trees; // returns true
+3 in trees; // returns true
+6 in trees; // returns false
+"bay" in trees; // returns false (you must specify the index number,
+ // not the value at that index)
+"length" in trees; // returns true (length is an Array property)
+
+// built-in objects
+"PI" in Math; // returns true
+var myString = new String("coral");
+"length" in myString; // returns true
+
+// Custom objects
+var mycar = { make: "Honda", model: "Accord", year: 1998 };
+"make" in mycar; // returns true
+"model" in mycar; // returns true
+</pre>
+
+<h4 id="instanceof" name="instanceof"><code>instanceof</code></h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/instanceof"><code>instanceof</code> operator</a> returns true if the specified object is of the specified object type. The syntax is:</p>
+
+<pre class="syntaxbox">objectName instanceof objectType
+</pre>
+
+<p>where <code>objectName</code> is the name of the object to compare to <code>objectType</code>, and <code>objectType</code> is an object type, such as {{jsxref("Date")}} or {{jsxref("Array")}}.</p>
+
+<p>Use <code>instanceof</code> when you need to confirm the type of an object at runtime. For example, when catching exceptions, you can branch to different exception-handling code depending on the type of exception thrown.</p>
+
+<p>For example, the following code uses <code>instanceof</code> to determine whether <code>theDay</code> is a <code>Date</code> object. Because <code>theDay</code> is a <code>Date</code> object, the statements in the <code>if</code> statement execute.</p>
+
+<pre class="brush: js">var theDay = new Date(1995, 12, 17);
+if (theDay instanceof Date) {
+ // statements to execute
+}
+</pre>
+
+<h3 id="Operator_precedence">Operator precedence</h3>
+
+<p>The <em>precedence</em> of operators determines the order they are applied when evaluating an expression. You can override operator precedence by using parentheses.</p>
+
+<p>The following table describes the precedence of operators, from highest to lowest.</p>
+
+<table class="standard-table">
+ <caption>Operator precedence</caption>
+ <thead>
+ <tr>
+ <th scope="col">Operator type</th>
+ <th scope="col">Individual operators</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>member</td>
+ <td><code>. []</code></td>
+ </tr>
+ <tr>
+ <td>call / create instance</td>
+ <td><code>() new</code></td>
+ </tr>
+ <tr>
+ <td>negation/increment</td>
+ <td><code>! ~ - + ++ -- typeof void delete</code></td>
+ </tr>
+ <tr>
+ <td>multiply/divide</td>
+ <td><code>* / %</code></td>
+ </tr>
+ <tr>
+ <td>addition/subtraction</td>
+ <td><code>+ -</code></td>
+ </tr>
+ <tr>
+ <td>bitwise shift</td>
+ <td><code>&lt;&lt; &gt;&gt; &gt;&gt;&gt;</code></td>
+ </tr>
+ <tr>
+ <td>relational</td>
+ <td><code>&lt; &lt;= &gt; &gt;= in instanceof</code></td>
+ </tr>
+ <tr>
+ <td>equality</td>
+ <td><code>== != === !==</code></td>
+ </tr>
+ <tr>
+ <td>bitwise-and</td>
+ <td><code>&amp;</code></td>
+ </tr>
+ <tr>
+ <td>bitwise-xor</td>
+ <td><code>^</code></td>
+ </tr>
+ <tr>
+ <td>bitwise-or</td>
+ <td><code>|</code></td>
+ </tr>
+ <tr>
+ <td>logical-and</td>
+ <td><code>&amp;&amp;</code></td>
+ </tr>
+ <tr>
+ <td>logical-or</td>
+ <td><code>||</code></td>
+ </tr>
+ <tr>
+ <td>conditional</td>
+ <td><code>?:</code></td>
+ </tr>
+ <tr>
+ <td>assignment</td>
+ <td><code>= += -= *= /= %= &lt;&lt;= &gt;&gt;= &gt;&gt;&gt;= &amp;= ^= |=</code></td>
+ </tr>
+ <tr>
+ <td>comma</td>
+ <td><code>,</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<p>A more detailed version of this table, complete with links to additional details about each operator, may be found in <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#Table">JavaScript Reference</a>.</p>
+
+<h2 id="Expressions">Expressions</h2>
+
+<p>An <em>expression</em> is any valid unit of code that resolves to a value.</p>
+
+<p>Every syntactically valid expression resolves to some value but conceptually, there are two types of expressions: with side effects (for example: those that assign value to a variable) and those that in some sense evaluate and therefore resolve to a value.</p>
+
+<p>The expression <code>x = 7</code> is an example of the first type. This expression uses the =<em> operator</em> to assign the value seven to the variable <code>x</code>. The expression itself evaluates to seven.</p>
+
+<p>The code <code>3 + 4</code> is an example of the second expression type. This expression uses the + operator to add three and four together without assigning the result, seven, to a variable.<br>
+ <br>
+ JavaScript has the following expression categories:</p>
+
+<ul>
+ <li>Arithmetic: evaluates to a number, for example 3.14159. (Generally uses {{ web.link("#Arithmetic_operators", "arithmetic operators") }}.)</li>
+ <li>String: evaluates to a character string, for example, "Fred" or "234". (Generally uses {{ web.link("#String_operators", "string operators") }}.)</li>
+ <li>Logical: evaluates to true or false. (Often involves {{ web.link("#Logical_operators", "logical operators") }}.)</li>
+ <li>Primary expressions: Basic keywords and general expressions in JavaScript.</li>
+ <li>Left-hand-side expressions: Left values are the destination of an assignment.</li>
+</ul>
+
+<h3 id="Primary_expressions">Primary expressions</h3>
+
+<p>Basic keywords and general expressions in JavaScript.</p>
+
+<h4 id="this" name="this"><code>this</code></h4>
+
+<p>Use the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/this"><code>this</code> keyword</a> to refer to the current object. In general, <code>this</code> refers to the calling object in a method. Use <code>this</code> either with the dot or the bracket notation:</p>
+
+<pre class="syntaxbox">this["propertyName"]
+this.propertyName
+</pre>
+
+<p>Suppose a function called <code>validate</code> validates an object's <code>value</code> property, given the object and the high and low values:</p>
+
+<pre class="brush: js">function validate(obj, lowval, hival){
+ if ((obj.value &lt; lowval) || (obj.value &gt; hival))
+ console.log("Invalid Value!");
+}
+</pre>
+
+<p>You could call <code>validate</code> in each form element's <code>onChange</code> event handler, using <code>this</code> to pass it the form element, as in the following example:</p>
+
+<pre class="brush: html"></pre>
+
+<p>Enter a number between 18 and 99:</p>
+
+<p><input></p>
+
+<h4 id="Grouping_operator">Grouping operator</h4>
+
+<p>The grouping operator <code>( )</code> controls the precedence of evaluation in expressions. For example, you can override multiplication and division first, then addition and subtraction to evaluate addition first.</p>
+
+<pre class="brush:js">var a = 1;
+var b = 2;
+var c = 3;
+
+// default precedence
+a + b * c // 7
+// evaluated by default like this
+a + (b * c) // 7
+
+// now overriding precedence
+// addition before multiplication
+(a + b) * c // 9
+
+// which is equivalent to
+a * c + b * c // 9
+</pre>
+
+<h4 id="Comprehensions">Comprehensions</h4>
+
+<p>Comprehensions are an experimental JavaScript feature, targeted to be included in a future ECMAScript version. There are two versions of comprehensions:</p>
+
+<dl>
+ <dt>{{experimental_inline}} {{jsxref("Operators/Array_comprehensions", "[for (x of y) x]")}}</dt>
+ <dd>Array comprehensions.</dd>
+ <dt>{{experimental_inline}} {{jsxref("Operators/Generator_comprehensions", "(for (x of y) y)")}}</dt>
+ <dd>Generator comprehensions.</dd>
+</dl>
+
+<p>Comprehensions exist in many programming languages and allow you to quickly assemble a new array based on an existing one, for example.</p>
+
+<pre class="brush:js">[for (i of [ 1, 2, 3 ]) i*i ];
+// [ 1, 4, 9 ]
+
+var abc = [ "A", "B", "C" ];
+[for (letter of abc) letter.toLowerCase()];
+// [ "a", "b", "c" ]</pre>
+
+<h3 id="Left-hand-side_expressions">Left-hand-side expressions</h3>
+
+<p>Left values are the destination of an assignment.</p>
+
+<h4 id="new" name="new"><code>new</code></h4>
+
+<p>You can use the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/new"><code>new</code> operator</a> to create an instance of a user-defined object type or of one of the built-in object types. Use <code>new</code> as follows:</p>
+
+<pre class="brush: js">var objectName = new objectType([param1, param2, ..., paramN]);
+</pre>
+
+<h4 id="super">super</h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/super">super keyword</a> is used to call functions on an object's parent. It is useful with <a href="/en-US/docs/Web/JavaScript/Reference/Classes">classes</a> to call the parent constructor, for example.</p>
+
+<pre class="syntaxbox">super([arguments]); // calls the parent constructor.
+super.functionOnParent([arguments]);
+</pre>
+
+<h4 id="Spread_operator">Spread operator</h4>
+
+<p>The <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator">spread operator</a> allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected.</p>
+
+<p><strong>Example:</strong> Today if you have an array and want to create a new array with the existing one being part of it, the array literal syntax is no longer sufficient and you have to fall back to imperative code, using a combination of <code>push</code>, <code>splice</code>, <code>concat</code>, etc. With spread syntax this becomes much more succinct:</p>
+
+<pre class="brush: js">var parts = ['shoulder', 'knees'];
+var lyrics = ['head', ...parts, 'and', 'toes'];</pre>
+
+<p>Similarly, the spread operator works with function calls:</p>
+
+<pre class="brush: js">function f(x, y, z) { }
+var args = [0, 1, 2];
+f(...args);</pre>
+
+<div>{{PreviousNext("Web/JavaScript/Guide/Funktionen", "Web/JavaScript/Guide/Numbers_and_dates")}}</div>