3.9 The Predominance of Operators

Hello everyone and welcome to this video where we're going to talk about operator precedence. When you're working with complex expressions, one thing you need to consider is operator precedence. Let me show you an example, let's declare "x" and set it to 2 + 3 x 4. What do you think of the result of this expression? Well let's record this and take a look. So we get 14, the reason is that the multiplication operator has a higher priority, in this expression is evaluated first so 3 x 4 = 12 The result is added to 2. Now all these operators you have learned in this section have their own priority. It is difficult to remember which operator has higher or lower priority. So, when working with complex expressions you can use parentheses to determine how these operators are applied. For example here we can put parentheses around 2 + 3, which means that this expression is evaluated first, so we get 5 and then the result is multiplied by 4, so now if we save the changes we get 20. That's it for this little demonstration on the different types of priority in JavaScript, let's meet again for a very next video.