Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JS Puzzles · Const

Operator precedence

Operator precedence determines the default order for applying operators in a JavaScript expression. Higher precedence runs first, equal precedence proceeds left to right, and parentheses can override the order.

How it works

JavaScript assigns each operator a precedence level that determines the default grouping of an expression. A higher number runs first; operators with equal precedence are processed from left to right, and parentheses can override the default order.

Key points

  • Precedence determines the default order in which multiple operators in one expression are applied.
  • Each operator has a numeric precedence level.
  • A larger precedence number means the operator is applied before one with a smaller number.
  • Multiplication has higher precedence than addition, so it is grouped first in an unparenthesized expression.
  • Unary plus has precedence 14 in the documented precedence table.

Common mistakes

  • Parentheses override the default precedence, so use them when the intended grouping differs from JavaScript’s normal order.
  • Operators at the same precedence level are evaluated from left to right.

Example: Precedence and parentheses

const result = 1 + 2 * 3;
const grouped = (1 + 2) * 3;
console.log(result);  // 7
console.log(grouped); // 9

Multiplication runs before addition by default, while parentheses explicitly make addition run first.

When to use it

Read arithmetic expressions

Predict the result of arithmetic expressions without running them.

Clarify evaluation order

Make an expression’s intended grouping explicit.

Understand assignments

Ensure calculations occur before storing a result.

  • Basic operators, maths
  • Assignment
  • Unary operators
  • Exponentiation
  • Multiplication
  • Division
  • Addition
  • Subtraction

Source: Basic operators, maths. Checked 2026-10-15.