← BYTES
JavaScript·Starter·Ref: 3.1.8
What does the `+` operator do when used between a string and a number, e.g. `"5" + 3`?
Have a question about this video? Mention reference 3.1.8 when you contact us.
a.Throws a TypeError
b.Converts the string to a number and adds them, producing 8
c.Converts the number to a string and concatenates them, producing "53"
d.Returns NaN
When `+` sees any string operand, JavaScript coerces the other operand to a string and concatenates rather than performing numeric addition -- a frequent source of confusion since `-`, `*`, `/` all coerce toward numbers instead.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES318#JavaScript