Update article.md
This commit is contained in:
parent
9c74908612
commit
fc7bfbb993
1 changed files with 10 additions and 10 deletions
|
@ -194,22 +194,22 @@ Here's an extract from the [precedence table](https://developer.mozilla.org/en-U
|
|||
| Precedence | Name | Sign |
|
||||
|------------|------|------|
|
||||
| ... | ... | ... |
|
||||
| 16 | unary plus | `+` |
|
||||
| 16 | unary negation | `-` |
|
||||
| 15 | exponentiation | `**` |
|
||||
| 14 | multiplication | `*` |
|
||||
| 14 | division | `/` |
|
||||
| 13 | addition | `+` |
|
||||
| 13 | subtraction | `-` |
|
||||
| 15 | unary plus | `+` |
|
||||
| 15 | unary negation | `-` |
|
||||
| 14 | exponentiation | `**` |
|
||||
| 13 | multiplication | `*` |
|
||||
| 13 | division | `/` |
|
||||
| 12 | addition | `+` |
|
||||
| 12 | subtraction | `-` |
|
||||
| ... | ... | ... |
|
||||
| 3 | assignment | `=` |
|
||||
| 2 | assignment | `=` |
|
||||
| ... | ... | ... |
|
||||
|
||||
As we can see, the "unary plus" has a priority of `16` which is higher than the `13` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition.
|
||||
As we can see, the "unary plus" has a priority of `15` which is higher than the `13` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition.
|
||||
|
||||
## Assignment
|
||||
|
||||
Let's note that an assignment `=` is also an operator. It is listed in the precedence table with the very low priority of `3`.
|
||||
Let's note that an assignment `=` is also an operator. It is listed in the precedence table with the very low priority of `2`.
|
||||
|
||||
That's why, when we assign a variable, like `x = 2 * 2 + 1`, the calculations are done first and then the `=` is evaluated, storing the result in `x`.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue