diff options
author | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:49:24 +0100 |
---|---|---|
committer | Florian Merz <me@fiji-flo.de> | 2021-02-11 14:49:24 +0100 |
commit | de5c456ebded0e038adbf23db34cc290c8829180 (patch) | |
tree | 2819c07a177bb7ec5f419f3f6a14270d6bcd7fda /files/pl/web/javascript/reference/operators/operator_precedence | |
parent | 8260a606c143e6b55a467edf017a56bdcd6cba7e (diff) | |
download | translated-content-de5c456ebded0e038adbf23db34cc290c8829180.tar.gz translated-content-de5c456ebded0e038adbf23db34cc290c8829180.tar.bz2 translated-content-de5c456ebded0e038adbf23db34cc290c8829180.zip |
unslug pl: move
Diffstat (limited to 'files/pl/web/javascript/reference/operators/operator_precedence')
-rw-r--r-- | files/pl/web/javascript/reference/operators/operator_precedence/index.html | 336 |
1 files changed, 336 insertions, 0 deletions
diff --git a/files/pl/web/javascript/reference/operators/operator_precedence/index.html b/files/pl/web/javascript/reference/operators/operator_precedence/index.html new file mode 100644 index 0000000000..87765f3e1a --- /dev/null +++ b/files/pl/web/javascript/reference/operators/operator_precedence/index.html @@ -0,0 +1,336 @@ +--- +title: Pierwszeństwo operatorów +slug: Web/JavaScript/Referencje/Operatory/Pierwszeństwo_operatorów +tags: + - JavaScript + - Operator + - pierwszeństwo +translation_of: Web/JavaScript/Reference/Operators/Operator_Precedence +--- +<div>{{jsSidebar("Operators")}}</div> + +<div></div> + +<div>Pierwszeństwo operatorów ustala kolejność, w jakiej operatory są ewaluowane. Operatory z wyższym pierwszeństwem są ewaluowane jako pierwsze.</div> + +<div></div> + +<p>Prosty przykład:</p> + +<pre class="brush: js notranslate">3 + 4 * 5 // zwraca 23 +</pre> + +<p>Operator mnożenia ("<code>*</code>") ma wyższe pierwszeństwo niż operator dodawania ("<code>+</code>") i dlatego będzie ewaluowany jako pierwszy.</p> + +<h2 id="Associativity" name="Associativity">Łączność</h2> + +<p>Łączność określa kolejność, w jakiej przetwarzane są operatory o takim samym pierwszeństwie. Przykłądowo, rozważny wyrażenie:</p> + +<pre class="syntaxbox notranslate">a OP b OP c +</pre> + +<p>Jeżeli <code>OP<sub>1</sub></code> and <code>OP<sub>2 </sub></code>mają różne poziomy pierwszeństwa operatorów (patrz tabela poniżej), operator z wyższym poziomem pierwszeństwa zostanie wykonany jako pierwszy, a kolejność zapisu nie ma znaczenia. Zwróćmy uwagę na w poniższym przykładzie, że mnożenie ma wyższy poziom pierwszeństwa i tym samym zostanie wykonane jako pierwsze, pomimo tego, że to dodawanie jest zapisane w kodzie jako pierwsze.</p> + +<pre class="notranslate">console.log(3 + 10 * 2); // wynik 23 +console.log(3 + (10 * 2)); // wynik 23 ponieważ nawiasy tutaj nie mają znaczenia +console.log((3 + 10) * 2); // wynik 26 ponieważ nawiasy zmieniają kolejność działań</pre> + +<p>Lewo-łączność (od lewej do prawej) oznacza, iż będzie ono przetworzone jako <code>(a OP b) OP c</code>, podczas gdy prawo-łączność (od prawej do lewej) oznacza, iż będzie ono zinterpretowane jako <code>a OP (b OP c)</code>. Operatory przypisania są prawo-łączne, więc możesz napisać:</p> + +<pre class="brush: js notranslate">a = b = 5; +</pre> + +<p>oczekując, że <code>a</code> i <code>b</code> otrzymają wartość 5. Wynika to z faktu, iż operator przypisania zwraca wartość, która jest przypisana. Najpierw wartość <code>b</code> ustawiana jest na 5, a następnie wartość zmiennej <code>a</code> jest ustawiana na wartość <code>b</code>.</p> + +<h2 id="Tabela" name="Tabela">Tabela</h2> + +<p>Poniższa tabela uporządkowana jest od najwyższego (19) do najniższego (0) pierwszeństwa.</p> + +<table class="fullwidth-table"> + <tbody> + <tr> + <th>Pierwszeństwo</th> + <th>Rodzaj operatora</th> + <th>Łączność</th> + <th>Operator</th> + </tr> + <tr> + <td>19</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Grouping">Grouping</a></td> + <td>n/a</td> + <td><code>( … )</code></td> + </tr> + <tr> + <td rowspan="3">18</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Dot_notation">Member Access</a></td> + <td>left-to-right</td> + <td><code>… . …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_Accessors#Dot_notation">Computed Member Access</a></td> + <td>left-to-right</td> + <td><code>… [ … ]</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Special/new" title="JavaScript/Reference/Operators/Special_Operators/new_Operator">new</a> (z listą argumentów)</td> + <td>n/a</td> + <td><code>new … ( … )</code></td> + </tr> + <tr> + <td rowspan="2">17</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions" title="JavaScript/Reference/Operators/Special_Operators/function_call">Wywołanie funkcji</a></td> + <td>left-to-right</td> + <td><code>… ( <var>… </var>)</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new" title="JavaScript/Reference/Operators/Special_Operators/new_Operator">new</a> (bez listy argumentów)</td> + <td>right-to-left</td> + <td><code>new …</code></td> + </tr> + <tr> + <td rowspan="2">16</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment" title="JavaScript/Reference/Operators/Arithmetic_Operators">Postinkrementacja</a></td> + <td>n/a</td> + <td><code>… ++</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement" title="JavaScript/Reference/Operators/Arithmetic_Operators">Postdekrementacja</a></td> + <td>n/a</td> + <td><code>… --</code></td> + </tr> + <tr> + <td rowspan="9">15</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_NOT" title="JavaScript/Reference/Operators/Logical_Operators">Negacja logiczna (NOT)</a></td> + <td>right-to-left</td> + <td><code>! …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_NOT" title="JavaScript/Reference/Operators/Bitwise_Operators">Negacja bitowa (NOT)</a></td> + <td>right-to-left</td> + <td><code>~ …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_plus" title="JavaScript/Reference/Operators/Arithmetic_Operators">Unary Plus</a></td> + <td>right-to-left</td> + <td><code>+ …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Unary_negation" title="JavaScript/Reference/Operators/Arithmetic_Operators">Unary Negation</a></td> + <td>right-to-left</td> + <td><code>- …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Increment" title="JavaScript/Reference/Operators/Arithmetic_Operators">Preinkrementacja</a></td> + <td>right-to-left</td> + <td><code>++ …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Decrement" title="JavaScript/Reference/Operators/Arithmetic_Operators">Predekrementacja</a></td> + <td>right-to-left</td> + <td><code>-- …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof" title="JavaScript/Reference/Operators/Special_Operators/typeof_Operator">typeof</a></td> + <td>right-to-left</td> + <td><code>typeof …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void" title="JavaScript/Reference/Operators/Special_Operators/void_Operator">void</a></td> + <td>right-to-left</td> + <td><code>void …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete" title="JavaScript/Reference/Operators/Special_Operators/delete_Operator">delete</a></td> + <td>right-to-left</td> + <td><code>delete …</code></td> + </tr> + <tr> + <td rowspan="3">14</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Multiplication" title="JavaScript/Reference/Operators/Arithmetic_Operators">Mnożenie</a></td> + <td>left-to-right</td> + <td><code>… * …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Division" title="JavaScript/Reference/Operators/Arithmetic_Operators">Dzielenie</a></td> + <td>left-to-right</td> + <td><code>… / …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder" title="JavaScript/Reference/Operators/Arithmetic_Operators">Reszta z dzielenia</a></td> + <td>left-to-right</td> + <td><code>… % …</code></td> + </tr> + <tr> + <td rowspan="2">13</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition" title="JavaScript/Reference/Operators/Arithmetic_Operators">Dodawanie</a></td> + <td>left-to-right</td> + <td><code>… + …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Subtraction" title="JavaScript/Reference/Operators/Arithmetic_Operators">Odejmowanie</a></td> + <td>left-to-right</td> + <td><code>… - …</code></td> + </tr> + <tr> + <td rowspan="3">12</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitowe przesunięcie w lewo</a></td> + <td>left-to-right</td> + <td><code>… << …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitowe przesunięcie w prawo</a></td> + <td>left-to-right</td> + <td><code>… >> …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitowe przesunięcie w prawo bez znaku</a></td> + <td>left-to-right</td> + <td><code>… >>> …</code></td> + </tr> + <tr> + <td rowspan="6">11</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Mniejsze niż</a></td> + <td>left-to-right</td> + <td><code>… < …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Less_than__or_equal_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Mniejsze lub równe</a></td> + <td>left-to-right</td> + <td><code>… <= …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Większe niż</a></td> + <td>left-to-right</td> + <td><code>… > …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Greater_than_or_equal_operator" title="JavaScript/Reference/Operators/Comparison_Operators">Większe lub równe</a></td> + <td>left-to-right</td> + <td><code>… >= …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in" title="JavaScript/Reference/Operators/Special_Operators/in_Operator">in</a></td> + <td>left-to-right</td> + <td><code>… in …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof" title="JavaScript/Reference/Operators/Special_Operators/instanceof_Operator">instanceof</a></td> + <td>left-to-right</td> + <td><code>… instanceof …</code></td> + </tr> + <tr> + <td rowspan="4">10</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Equality" title="JavaScript/Reference/Operators/Comparison_Operators">Równość</a></td> + <td>left-to-right</td> + <td><code>… == …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Inequality" title="JavaScript/Reference/Operators/Comparison_Operators">Nierówność</a></td> + <td>left-to-right</td> + <td><code>… != …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Identity" title="JavaScript/Reference/Operators/Comparison_Operators">Ścisła równość</a></td> + <td>left-to-right</td> + <td><code>… === …</code></td> + </tr> + <tr> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Nonidentity" title="JavaScript/Reference/Operators/Comparison_Operators">Ścisła nierówność</a></td> + <td>left-to-right</td> + <td><code>… !== …</code></td> + </tr> + <tr> + <td>9</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_AND" title="JavaScript/Reference/Operators/Bitwise_Operators">Koniunkcja bitowa (AND)</a></td> + <td>left-to-right</td> + <td><code>… & …</code></td> + </tr> + <tr> + <td>8</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_XOR" title="JavaScript/Reference/Operators/Bitwise_Operators">Bitowa alternatywa wykluczająca (XOR)</a></td> + <td>left-to-right</td> + <td><code>… ^ …</code></td> + </tr> + <tr> + <td>7</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Bitwise_OR" title="JavaScript/Reference/Operators/Bitwise_Operators">Alternatywa bitowa (OR)</a></td> + <td>left-to-right</td> + <td><code>… | …</code></td> + </tr> + <tr> + <td>6</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_AND" title="JavaScript/Reference/Operators/Logical_Operators">Koniunkcja logiczna (AND)</a></td> + <td>left-to-right</td> + <td><code>… && …</code></td> + </tr> + <tr> + <td>5</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR" title="JavaScript/Reference/Operators/Logical_Operators">Alternatywa logiczna (OR)</a></td> + <td>left-to-right</td> + <td><code>… || …</code></td> + </tr> + <tr> + <td>4</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator" title="JavaScript/Reference/Operators/Special_Operators/Conditional_Operator">Warunek</a></td> + <td>right-to-left</td> + <td><code>… ? … : …</code></td> + </tr> + <tr> + <td rowspan="12">3</td> + <td rowspan="12"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Assignment_Operators" title="JavaScript/Reference/Operators/Assignment_Operators">Przypisanie</a></td> + <td rowspan="12">right-to-left</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>2</td> + <td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield" title="JavaScript/Reference/Operators/yield">yield</a></td> + <td>right-to-left</td> + <td><code>yield …</code></td> + </tr> + <tr> + <td>1</td> + <td><a href="https://developer.mozilla.org/en-US/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="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_Operator" title="JavaScript/Reference/Operators/Comma_Operator">Comma / Sequence</a></td> + <td>left-to-right</td> + <td><code>… , …</code></td> + </tr> + </tbody> +</table> |