Read arithmetic expressions
Predict the result of arithmetic expressions without running them.
JS Puzzles · Const
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.
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.
const result = 1 + 2 * 3;
const grouped = (1 + 2) * 3;
console.log(result); // 7
console.log(grouped); // 9Multiplication runs before addition by default, while parentheses explicitly make addition run first.
Predict the result of arithmetic expressions without running them.
Make an expression’s intended grouping explicit.
Ensure calculations occur before storing a result.
Basic operators, mathsAssignmentUnary operatorsExponentiationMultiplicationDivisionAdditionSubtraction