Merge pull request #2839 from ruslauz/fix/operator-precedence
fixes operator precedence
This commit is contained in:
commit
843f945aa5
1 changed files with 6 additions and 6 deletions
|
@ -194,18 +194,18 @@ Here's an extract from the [precedence table](https://developer.mozilla.org/en-U
|
|||
| Precedence | Name | Sign |
|
||||
|------------|------|------|
|
||||
| ... | ... | ... |
|
||||
| 17 | unary plus | `+` |
|
||||
| 17 | unary negation | `-` |
|
||||
| 16 | exponentiation | `**` |
|
||||
| 15 | multiplication | `*` |
|
||||
| 15 | division | `/` |
|
||||
| 16 | unary plus | `+` |
|
||||
| 16 | unary negation | `-` |
|
||||
| 15 | exponentiation | `**` |
|
||||
| 14 | multiplication | `*` |
|
||||
| 14 | division | `/` |
|
||||
| 13 | addition | `+` |
|
||||
| 13 | subtraction | `-` |
|
||||
| ... | ... | ... |
|
||||
| 3 | assignment | `=` |
|
||||
| ... | ... | ... |
|
||||
|
||||
As we can see, the "unary plus" has a priority of `17` 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 `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.
|
||||
|
||||
## Assignment
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue