Arithmetic and Unary Operators
In short: the six arithmetic operators — + - * / % ** — combine two
values: add, subtract, multiply, divide, remainder, and raise to a power.
Unary operators act on a single value: +x converts x to a number,
-x flips its sign, and ++/-- step a number by one, either before or
after the expression's value is read. BigInt values (written 10n) have
their own arithmetic and refuse to mix with ordinary numbers — you must
convert one side explicitly.

Split the remainder from a total
% gives the remainder after division — useful for anything that wraps,
like converting seconds into minutes and leftover seconds:
7 % 3 is 1 — 3 goes into 7 twice, with 1 left over. 2 ** 10 is
1024 — ** is JavaScript's power operator. / always gives a full
decimal, 3.3333333333333335 — JavaScript has one number type, there's no
separate "integer division".
Convert a form value with unary plus
The unary + in front of a single value is a quick way to force a string
into a number — it's the same conversion Number() does, just shorter:
+raw is the number 42; typeof +raw confirms it's "number", not
"string". -raw does the same conversion and then negates it: -42.
Contrast this with binary +, which needs two values: 5 + "5" joins
text and gives "55", because one side is a string. The difference between
unary and binary + is entirely about how many values sit around it.
Read n++ before and after it runs
n++ (postfix) returns the old value and updates n afterwards;
++n (prefix) updates n first and returns the new value:
The first line prints 5 6 — n++ hands back 5 (its value before
incrementing), and only then does n become 6. The second prints 7 7
— ++n increments first, so both the returned value and n itself are
7. Mixing these up inside a larger expression is a classic source of
off-by-one bugs.
The trap: mixing BigInt with a regular number
BigInt exists for integers too large for the normal number type to
represent exactly. It refuses to silently combine with ordinary numbers:
This throws TypeError: Cannot mix BigInt and other types, use explicit conversions. Both sides must be the same kind: 10n + 5n gives 15n, or
convert explicitly with Number(10n) + 5 (losing BigInt's extra range) or
10n + BigInt(5).
Quick practice
What is 7 % 3?
What is typeof +"42"?
What does let n = 5; console.log(n++); print, and what is n afterwards?
What does 10n + 5 do?
What is 2 ** 10?
🎯 Your turn
Explain the difference between +"5" and 5 + "5", what each evaluates
to, and why 10n + 5 fails while 10n + 5n works.
Write your explanation and submit it — there's no code to run here, just your reasoning.
