diff options
Diffstat (limited to 'files/de/web/javascript/reference/operators/operator_precedence')
| -rw-r--r-- | files/de/web/javascript/reference/operators/operator_precedence/index.html | 318 |
1 files changed, 318 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/operators/operator_precedence/index.html b/files/de/web/javascript/reference/operators/operator_precedence/index.html new file mode 100644 index 0000000000..e258a96525 --- /dev/null +++ b/files/de/web/javascript/reference/operators/operator_precedence/index.html @@ -0,0 +1,318 @@ +--- +title: Operatorenpriorität +slug: Web/JavaScript/Reference/Operators/Operator_Precedence +tags: + - JavaScript + - Operator + - precedence +translation_of: Web/JavaScript/Reference/Operators/Operator_Precedence +--- +<p>{{jsSidebar("Operators")}}</p> + +<p>Die Operatorpriorität bestimmt, in welcher Reihenfolge Operatoren ausgeführt werden. Operatoren, die in der Rangfolge zuerst kommen, werden auch zuerst ausgeführt.</p> + +<p>{{EmbedInteractiveExample("pages/js/expressions-operatorprecedence.html")}}</p> + +<p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p> + +<h2 id="Assoziativität">Assoziativität</h2> + +<p>Assoziativität, bestimmt in welcher Reihenfolge Operatoren der selben Rangfolge ausgeführt werden. Betrachten wir als Beispiel den folgenden Ausdruck:</p> + +<pre>a OP b OP c +</pre> + +<p>Linksassoziativ (links nach rechts) bedeutet, dass der Code als <code>(a OP b) OP c</code> ausgeführt wird, während rechtssassoziativ (rechts nach links) heißt, dass der Code wie <code>a OP (b OP c)</code> ausgeführt wird. Zuordnungsoperatoren sind rechtssassoziativ, also kann man schreiben:</p> + +<pre>a = b = 5; +</pre> + +<p>mit dem erwarteten Resultat, dass sowohl <code>a</code> als auch <code>b</code> den Wert 5 haben. Das liegt daran, dass Zuordnungsopertoren den Wert zurükgeben, den sie zuerst zugeordnet haben: Zuerst wird <code>b</code> auf 5 gesetzt; daraufhin wird <code>a</code> auf 5, also den Rückgabewert von <code>b = 5</code>, gesetzt.</p> + +<h2 id="Tabelle">Tabelle</h2> + +<p>Die nachfolgende Tabelle geordnet von der höchsten (20) bis zur kleinsten (1) Priorität.</p> + +<table class="fullwidth-table"> + <tbody> + <tr> + <th>Priorität</th> + <th>Operator</th> + <th>Assoziativität</th> + <th>Einzelner Operator</th> + </tr> + <tr> + <td>20</td> + <td>{{jsxref("Operators/Grouping", "Gruppieren")}}</td> + <td>n/a</td> + <td><code>( … )</code></td> + </tr> + <tr> + <td colspan="1" rowspan="4">19</td> + <td>{{jsxref("Operators/Property_Accessors", "Eigenschaftszugriff", "#Dot_notation")}}</td> + <td>links nach rechts</td> + <td><code>… . …</code></td> + </tr> + <tr> + <td>{{jsxref("Operators/Property_Accessors", "Berechnete Eigenschaften Access","#Bracket_notation")}}</td> + <td>links nach rechts</td> + <td><code>… [ … ]</code></td> + </tr> + <tr> + <td>{{jsxref("Operators/new","new")}} (mit Argumentenliste)</td> + <td>n/a</td> + <td><code>new … ( … )</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Guide/Functions" title="JavaScript/Reference/Operators/Special_Operators/function_call">Funktionsaufruf</a></td> + <td>links nach rechts</td> + <td><code>… ( <var>… </var>)</code></td> + </tr> + <tr> + <td>18</td> + <td>{{jsxref("Operators/new","new")}} (ohne Argumentenliste)</td> + <td>rechts nach links</td> + <td><code>new …</code></td> + </tr> + <tr> + <td rowspan="2">17</td> + <td>{{jsxref("Operators/Arithmetic_Operators","Postfix Inkrement","#Increment")}}</td> + <td colspan="1" rowspan="2">n/a</td> + <td><code>… ++</code></td> + </tr> + <tr> + <td>{{jsxref("Operators/Arithmetic_Operators","Postfix Dekrement","#Decrement")}}</td> + <td><code>… --</code></td> + </tr> + <tr> + <td colspan="1" rowspan="10">16</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT" title="JavaScript/Reference/Operators/Logical_Operators">Logisches NICHT</a></td> + <td colspan="1" rowspan="10">rechts nach links</td> + <td><code>! …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweises NICHT</a></td> + <td><code>~ …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus" title="JavaScript/Reference/Operators/Arithmetic_Operators">Unäres Plus</a></td> + <td><code>+ …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation" title="JavaScript/Reference/Operators/Arithmetic_Operators">Unäres Minus</a></td> + <td><code>- …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment" title="JavaScript/Reference/Operators/Arithmetic_Operators">Prefix Inkrement</a></td> + <td><code>++ …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement" title="JavaScript/Reference/Operators/Arithmetic_Operators">Prefix Dekrement</a></td> + <td><code>-- …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/typeof" title="JavaScript/Reference/Operators/Special_Operators/typeof_Operator">typeof</a></td> + <td><code>typeof …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/void" title="JavaScript/Reference/Operators/Special_Operators/void_Operator">void</a></td> + <td><code>void …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/delete" title="JavaScript/Reference/Operators/Special_Operators/delete_Operator">delete</a></td> + <td><code>delete …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/await">await</a></td> + <td><code>await …</code></td> + </tr> + <tr> + <td>15</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation" title="JavaScript/Reference/Operators/Arithmetic_Operators">Potenzierung</a></td> + <td>rechts nach links</td> + <td><code>… ** …</code></td> + </tr> + <tr> + <td rowspan="3">14</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication" title="JavaScript/Reference/Operators/Arithmetic_Operators">Multiplikation</a></td> + <td colspan="1" rowspan="3">links nach rechts</td> + <td><code>… * …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division" title="JavaScript/Reference/Operators/Arithmetic_Operators">Division</a></td> + <td><code>… / …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder" title="JavaScript/Reference/Operators/Arithmetic_Operators">Rest</a></td> + <td><code>… % …</code></td> + </tr> + <tr> + <td rowspan="2">13</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition" title="JavaScript/Reference/Operators/Arithmetic_Operators">Addition</a></td> + <td colspan="1" rowspan="2">links nach rechts</td> + <td><code>… + …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction" title="JavaScript/Reference/Operators/Arithmetic_Operators">Subtraktion</a></td> + <td><code>… - …</code></td> + </tr> + <tr> + <td rowspan="3">12</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweise Linksverschiebung</a></td> + <td colspan="1" rowspan="3">links nach rechts</td> + <td><code>… << …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweise Rechtsverschiebung</a></td> + <td><code>… >> …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweise Vorzeichnelose Rechtsverschiebung</a></td> + <td><code>… >>> …</code></td> + </tr> + <tr> + <td rowspan="6">11</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Kleiner als</a></td> + <td colspan="1" rowspan="6">links nach rechts</td> + <td><code>… < …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than__or_equal_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Kleiner als oder gleich</a></td> + <td><code>… <= …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Größer als</a></td> + <td><code>… > …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Größer als oder gleich</a></td> + <td><code>… >= …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/in" title="JavaScript/Reference/Operators/Special_Operators/in_Operator">in</a></td> + <td><code>… in …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/instanceof" title="JavaScript/Reference/Operators/Special_Operators/instanceof_Operator">instanceof</a></td> + <td><code>… instanceof …</code></td> + </tr> + <tr> + <td rowspan="4">10</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality" title="JavaScript/Reference/Operators/Comparison_Operators">Gleichheit</a></td> + <td colspan="1" rowspan="4">links nach rechts</td> + <td><code>… == …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality" title="JavaScript/Reference/Operators/Comparison_Operators">Ungleichheit</a></td> + <td><code>… != …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity" title="JavaScript/Reference/Operators/Comparison_Operators">Strikte Gleichheit</a></td> + <td><code>… === …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity" title="JavaScript/Reference/Operators/Comparison_Operators">Strikte Ungleichheit</a></td> + <td><code>… !== …</code></td> + </tr> + <tr> + <td>9</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweises UND</a></td> + <td>links nach rechts</td> + <td><code>… & …</code></td> + </tr> + <tr> + <td>8</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweises Exklusiv ODER (XOR)</a></td> + <td>links nach rechts</td> + <td><code>… ^ …</code></td> + </tr> + <tr> + <td>7</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitweises ODER</a></td> + <td>links nach rechts</td> + <td><code>… | …</code></td> + </tr> + <tr> + <td>6</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND" title="JavaScript/Reference/Operators/Logical_Operators">Logisches UND</a></td> + <td>links nach rechts</td> + <td><code>… && …</code></td> + </tr> + <tr> + <td>5</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR" title="JavaScript/Reference/Operators/Logical_Operators">Logisches ODER</a></td> + <td>links nach rechts</td> + <td><code>… || …</code></td> + </tr> + <tr> + <td>4</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Conditional_Operator" title="JavaScript/Reference/Operators/Special_Operators/Conditional_Operator">Bedingt</a></td> + <td>rechts nach links</td> + <td><code>… ? … : …</code></td> + </tr> + <tr> + <td rowspan="13">3</td> + <td rowspan="13"><a href="/de/docs/Web/JavaScript/Reference/Operators/Assignment_Operators" title="JavaScript/Reference/Operators/Assignment_Operators">Zuweisung</a></td> + <td rowspan="13">rechts nach links</td> + <td><code>… = …</code></td> + </tr> + <tr> + <td><code>… += …</code></td> + </tr> + <tr> + <td><code>… -= …</code></td> + </tr> + <tr> + <td><code>… **= …</code></td> + </tr> + <tr> + <td><code>… *= …</code></td> + </tr> + <tr> + <td><code>… /= …</code></td> + </tr> + <tr> + <td><code>… %= …</code></td> + </tr> + <tr> + <td><code>… <<= …</code></td> + </tr> + <tr> + <td><code>… >>= …</code></td> + </tr> + <tr> + <td><code>… >>>= …</code></td> + </tr> + <tr> + <td><code>… &= …</code></td> + </tr> + <tr> + <td><code>… ^= …</code></td> + </tr> + <tr> + <td><code>… |= …</code></td> + </tr> + <tr> + <td colspan="1" rowspan="2">2</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/yield" title="JavaScript/Reference/Operators/yield">yield</a></td> + <td colspan="1" rowspan="2">rechts nach links</td> + <td><code>yield …</code></td> + </tr> + <tr> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/yield*" title="JavaScript/Reference/Operators/yield">yield*</a></td> + <td><code>yield* …</code></td> + </tr> + <tr> + <td>1</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Spread_operator" title="JavaScript/Reference/Operators/Spread_operator">Spread</a></td> + <td>n/a</td> + <td><code>...</code> …</td> + </tr> + <tr> + <td>0</td> + <td><a href="/de/docs/Web/JavaScript/Reference/Operators/Comma_Operator" title="JavaScript/Reference/Operators/Comma_Operator">Komma / Sequenz</a></td> + <td>links nach rechts</td> + <td><code>… , …</code></td> + </tr> + </tbody> +</table> |
