Tsallaka zuwa abun ciki
Justice Tech School

Operator Precedence and Assignment

Operators have precedence, like in maths: * before +, && before ||. Use parentheses for clarity. Compound assignments such as +=, -=, **= and ??= shorten updates.

Example
let x = 2 + 3 * 4;
let y = (2 + 3) * 4;
let z = 5;
z += 3; z **= 2;
console.log(x, y, z);

Exercise

Add and assign.

n  5

Quiz Test

Which runs first in 2 + 3 * 4?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.