Your product could be here, in front of thousands of JavaScript developers. Sponsor this spot →
JavaScript Quiz

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

  1. Why does ('b' + 'a' + + 'a' + 'a') return "banana"?
  2. Why is "a string" instanceof String false?
  3. Why does 1 + "2" + "2" return "122"?
  4. What does String.raw do in JavaScript?
  5. Why is "10" < "9" true in JavaScript?
  6. Can you change a character in a JavaScript string?
  7. Why does replace() only change the first match?

More topics