mozilla
Wyniki wyszukiwania

    Pierwszeństwo operatorów

    UWAGA: Tłumaczenie tej strony nie zostało zakończone.
    Może być ona niekompletna lub wymagać korekty.
    Chcesz pomóc? | Dokończ tłumaczenie | Sprawdź ortografię | Więcej takich stron+.

    Podsumowanie

    Operator precedence determines the order in which operators are evaluated. Operators with higher precedence are evaluated first.

    Prosty przykład:

    3 + 4 * 5 // zwraca 23	 
    

    The multiplication operator ("*") has higher precedence than the addition operator ("+") and thus will be evaluated first.

    Associativity

    Associativity determines the order in which operators of the same precedence are processed. For example, consider an expression:

    a OP b OP c
    

    Left-associativity (left-to-right) means that it is processed as (a OP b) OP c, while right-associativity (right-to-left) means it is interpreted as a OP (b OP c). Assignment operators are right-associative, so you can write:

    a = b = 5;
    

    with the expected result that a and b get the value 5. This is because the assignment operator returns the value that it assigned. First, b is set to 5. Then the a is set to the value of b.

    Tabela

    The following table is ordered from highest (1) to lowest (17) precedence.

    </tr>
    Precedence Operator type Associativity Individual operators
    1 pamięci left-to-right .
    []
    new right-to-left new
    2 function call left-to-right ()
    3 increment n/a ++
    decrement n/a --
    4 logical-not right-to-left !
    bitwise not right-to-left ~
    unary + right-to-left +
    unary negation right-to-left -
    typeof right-to-left typeof
    void right-to-left void
    delete right-to-left delete
    5 multiplication left-to-right *
    division left-to-right /
    modulus left-to-right %
    6 addition left-to-right +
    subtraction left-to-right -
    7 bitwise shift left-to-right <<
    >>
    >>>
    8 relational left-to-right <
    <=
    >
    >=
    in left-to-right in
    instanceof left-to-right instanceof
    9 equality left-to-right ==
    !=
    ===
    !==
    10 bitwise-and left-to-right &
    11 bitwise-xor left-to-right ^
    12 bitwise-or left-to-right |
    13 logiczny-and left-to-right &&
    14 logiczny-or left-to-right ||
    15 warunkowy right-to-left ?:
    16 przypisania right-to-left =
    +=
    -=
    *=
    /=
    %=
    <<=
    >>=
    >>>=
    &=
    ^=
    |=
    17 przecinkowy left-to-right ,


    Autorzy i etykiety dokumentu

    Contributors to this page: Ptak82, teoli, Internauta1024A, Mgjbot
    Ostatnia aktualizacja: teoli,