Type Coercion with String
Multiple Choice Medium
Question
What does "5" + 3 return in JavaScript?
Hint
The + operator with a string does concatenation.
Explanation
"5" + 3 returns "53" (string). When one operand is a string, the + operator coerces the other to a string and concatenates. This is a common source of bugs. In contrast, "5" - 3 returns 2 (number) because - only works on numbers, so "5" is coerced to 5.
Related Resources
Related Lessons
- Data Types
Learn about primitive data types.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.