Operator Precedence
noun
say it: “OP-er-ay-ter PRES-ih-dens” /ˈɒpəreɪtər ˈprɛsɪdəns/
The order JavaScript works out a calculation in: parentheses first, then **, then * / %, then + and -.
What is Operator Precedence in JavaScript?
Operator Precedence — The order JavaScript works out an expression in: parentheses first, then **, then *, / and %, then + and -, left to right within each level. Add parentheses when you want a different order, or to make the order clear.
console.log(5 + 2 * 4); // 13: 2 * 4 first, then + 5
console.log((5 + 2) * 4); // 28: the parentheses first
In a sentence
- “Because of operator precedence, 2 + 3 * 4 is 14, not 20.”
Level: Novice · More JavaScript terms at this level
Updated