Recall & Review
beginner
What is operator precedence in JavaScript?
Operator precedence determines the order in which operators are evaluated in an expression. Operators with higher precedence are evaluated before those with lower precedence.
Click to reveal answer
beginner
Which operator has higher precedence: multiplication (*) or addition (+)?
Multiplication (*) has higher precedence than addition (+), so it is evaluated first in an expression.
Click to reveal answer
beginner
How does parentheses affect operator precedence?
Parentheses have the highest precedence and force the expression inside them to be evaluated first, regardless of other operators.
Click to reveal answer
beginner
What is the result of the expression: 3 + 4 * 2?
The multiplication happens first: 4 * 2 = 8. Then addition: 3 + 8 = 11. So, the result is 11.
Click to reveal answer
beginner
True or False: The assignment operator (=) has higher precedence than addition (+).
False. The addition operator (+) has higher precedence than the assignment operator (=). So addition happens before assignment.
Click to reveal answer
Which operator is evaluated first in the expression: 5 + 3 * 2?
✗ Incorrect
Multiplication (*) has higher precedence than addition (+), so it is evaluated first.
What does parentheses do in an expression?
✗ Incorrect
Parentheses have the highest precedence and force the expression inside to be evaluated first.
Which operator has the lowest precedence?
✗ Incorrect
Assignment (=) has lower precedence than arithmetic operators like +, *, and **.
What is the result of: (2 + 3) * 4?
✗ Incorrect
Parentheses evaluated first: 2 + 3 = 5, then multiplied by 4 = 20.
In the expression 10 - 4 + 2, which operator is evaluated first?
✗ Incorrect
Subtraction and addition have the same precedence and are evaluated left to right, so subtraction happens first.
Explain how operator precedence affects the evaluation of the expression 8 + 2 * 5.
Think about which operation happens first without parentheses.
You got /3 concepts.
Describe the role of parentheses in changing the order of operations in JavaScript expressions.
Consider how parentheses can change 2 + 3 * 4 to (2 + 3) * 4.
You got /3 concepts.