Prioritet operatorów JavaScript
- Poprzednia strona Operatorzy JS
- Następna strona Wyrażenia JS
Precedence describes the order of execution of operations in arithmetic expressions.
instance
In traditional mathematics, multiplication is executed first:
let x = 100 + 50 * 3;
When using parentheses, the operation inside the parentheses is calculated first:
let x = (100 + 50) * 3;
When operators have the same precedence (such as + and -), they are calculated from left to right:
let x = 100 / 50 * 3;
operator precedence valueexpression inside parenthesesPrzedother expressions are calculated. function used in the result for other expressionsbeforeWykonaj. |
|||
value | operator | description | example |
---|---|---|---|
43 | ( ) | expression grouping | (100 + 50) * 3 |
17 | . | member | car.name |
17 | [] | member | car["name"] |
17 | ?. | optional chaining ES2020 | x ?. y |
17 | () | function call | myFunction() |
17 | new | parameterized construction | new Date("June 6,2025") |
16 | new | no parameter construction | new Date() |
increment operatorpostfix incrementPrzedprefix increment execution. |
|||
15 | ++ | postfix increment | i++ |
15 | -- | postfix decrement | i-- |
14 | ++ | prefix increment | ++i |
14 | -- | prefix decrement | --i |
NOT operator |
|||
14 | ! | logic NOT | !(x==y) |
14 | ~ | NOT | ~x |
Operator jednorodnikowy |
|||
14 | + | Jednorodnikowy dodatek | +x |
14 | - | Jednorodnikowy odjazd | -x |
14 | typeof | Typ danych | typeof x |
14 | void | Ewaluacja Void | void(0) |
14 | delete | Usunięcie atrybutu | delete myCar.color |
Operator arytmetycznyPotęgaPrzedWykonaj mnożenie. Mnożenie i dzieleniePrzedWykonaj dodawanie i odejmowanie. |
|||
13 | ** | Potęga ES2016 | 10 ** 2 |
12 | * | Mnożenie | 10 * 5 |
12 | / | Dzielenie | 10 / 5 |
12 | % | Reszta z dzielenia | 10 % 5 |
11 | + | Dodawanie | 10 + 5 |
11 | - | Odejmowanie | 10 - 5 |
11 | + | Łączenie | "Bill" + "Gates" |
Operator przesunięcia |
|||
10 | << | Przesunięcie w lewo | x << 2 |
10 | >> | Przesunięcie w prawo (z znakiem) | x >> 2 |
10 | >>> | Przesunięcie w prawo (bez znaku) | x >>> 2 |
Operator relacyjny |
|||
9 | in | Atrybut obiektu | "PI" in Math |
9 | instanceof | Przykładowa instancja obiektu | x instanceof Array |
Operator porównania |
|||
9 | < | Mniejszy | x < y |
9 | <= | Mniejszy lub równy | x <= y |
9 | > | Większy | x > y |
9 | >= | Równy lub większy | x >= Array |
8 | == | Równo | x == y |
8 | === | Rzeczywiste równo | x === y |
8 | != | Nie równo | x != y |
8 | !== | Rzeczywiste nie równo | x !== y |
Operator bitowy |
|||
7 | & | Bitwise AND | x & y |
6 | ^ | Bitwise XOR | x ^ y |
5 | | | Bitwise OR | x | y |
Operator logiczny |
|||
4 | && | Logiczne AND | x && y |
3 | || | Logiczne OR | x || y |
3 | ?? | Połączenie pustych wartości ES2020 | x ?? y |
Operator warunkowy (trójargumentowy) |
|||
2 | ? : | Warunek | ? "yes" : "no" |
Operator przypisaniaPrzypisanie w innych operacjachPóźniejWykonaj. |
|||
2 | = | Proste przypisanie | x = y |
2 | += | Przypisanie dodawania | x += y |
2 | -= | Przypisanie odejmowania | x -= y |
2 | *= | Przypisanie mnożenia | x *= y |
2 | **= | Przypisanie potęgi | x **= y |
2 | /= | Przypisanie dzielenia | x /= y |
2 | %= | Przypisanie reszty z dzielenia | x %= y |
2 | <<= | Przypisanie przesunięcia w lewo | x <<= y |
2 | >>= | Przypisanie przesunięcia w prawo | x >>= y |
2 | >>= | Przesunięcie w prawo bez znaku | x >>>= y |
2 | &= | AND przypisanie | x &= y |
2 | |= | OR przypisanie | x |= y |
2 | ^= | Przypisanie bitowe XOR | x ^= y |
2 | &= | Przypisanie logiczne AND | x &= y |
2 | ||= | Przypisanie logiczne OR | x ||= y |
2 | : | Przypisanie za pomocą kolona | x : 5 |
2 | => | Strzałka | x => y |
2 | yield | Zatrzymanie/odtworzenie | yield x |
2 | yield* | Delegacja | yield* x |
2 | ... | Rozszerzenie | ...x |
1 | , | Przecinek | x, y |
- Poprzednia strona Operatorzy JS
- Następna strona Wyrażenia JS