Operator Precedence
When an expression has multiple operators, JavaScript follows a strict order of operations — just like in math. Multiplication happens before addition. Parentheses override everything.
Here's a simplified precedence table (highest to lowest):
()— Grouping.,[],()— Member access, call!,~,++,--— Unary**,*,/,%— Multiplicative+,-— Additive<,>,<=,>=— Relational==,===,!=,!==— Equality&&— Logical AND||— Logical OR??— Nullish coalescing=,+=, etc. — Assignment
console.log(2 + 3 * 4);
console.log((2 + 3) * 4);
console.log(2 ** 3 + 1);
console.log(2 ** (3 + 1));
Try it Yourself →
When in doubt, add parentheses. They make your intent clear to both JavaScript and your fellow developers.