JavaScript Strings Quiz
Strings in JavaScript are primitives, but they behave like objects when you call methods on them. Add the + operator, which concatenates as soon as one operand is a string, and template literals with their own escape rules, and there’s plenty of room for surprises.
These questions cover string concatenation, primitive wrappers and tagged template literals like String.raw.
Strings questions
- Why does ('b' + 'a' + + 'a' + 'a') return "banana"?
- Why is "a string" instanceof String false?
- Why does 1 + "2" + "2" return "122"?
- What does String.raw do in JavaScript?
- Why is "10" < "9" true in JavaScript?
- Can you change a character in a JavaScript string?
- Why does replace() only change the first match?