From 69d180e028ccc1c5153eade1e6e2013fc6fa5f59 Mon Sep 17 00:00:00 2001 From: romanstetsyk <25715951+romanstetsyk@users.noreply.github.com> Date: Thu, 21 Jul 2022 20:59:18 +0100 Subject: [PATCH] Update the operator precedence table According to MDN, the precedence of unary plus, unary negation, exponentiation, multiplication, division, addition, and subtraction is 1 lower than it is in the document --- 1-js/02-first-steps/08-operators/article.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/08-operators/article.md b/1-js/02-first-steps/08-operators/article.md index fbf2cbf9..9d353e74 100644 --- a/1-js/02-first-steps/08-operators/article.md +++ b/1-js/02-first-steps/08-operators/article.md @@ -194,18 +194,18 @@ Here's an extract from the [precedence table](https://developer.mozilla.org/en-U | Precedence | Name | Sign | |------------|------|------| | ... | ... | ... | -| 15 | unary plus | `+` | -| 15 | unary negation | `-` | -| 14 | exponentiation | `**` | -| 13 | multiplication | `*` | -| 13 | division | `/` | -| 12 | addition | `+` | -| 12 | subtraction | `-` | +| 14 | unary plus | `+` | +| 14 | unary negation | `-` | +| 13 | exponentiation | `**` | +| 12 | multiplication | `*` | +| 12 | division | `/` | +| 11 | addition | `+` | +| 11 | subtraction | `-` | | ... | ... | ... | | 2 | assignment | `=` | | ... | ... | ... | -As we can see, the "unary plus" has a priority of `15` which is higher than the `12` 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 `14` which is higher than the `11` of "addition" (binary plus). That's why, in the expression `"+apples + +oranges"`, unary pluses work before the addition. ## Assignment