Skip to main content

JavaScript Strings

12 lessonsAbout 72 minutesIntermediate

This part of the JavaScript Tutorial runs from JavaScript Strings through to JavaScript String Immutability. There are 12 lessons here, and working through them takes about 72 minutes at a steady pace.

It follows on from JavaScript Type System, so finish that first if you have not already — the examples below assume you are comfortable with it.

Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.

  1. 1JavaScript StringsA JavaScript string holds text, written inside quotes.
  2. 2JavaScript Template LiteralsTemplate literals use backticks and let you put values directly inside text.
  3. 3JavaScript String Escape CharactersA backslash lets you put special characters inside a string.
  4. 4JavaScript String CasetoUpperCase and toLowerCase return a new string in a different case.
  5. 5JavaScript String Searchincludes, indexOf, startsWith and endsWith find text inside a string.
  6. 6JavaScript String sliceslice takes a piece out of a string without changing the original.
  7. 7JavaScript String replacereplace swaps one piece of text for another and returns a new string.
  8. 8JavaScript String splitsplit turns a string into an array by cutting it at a separator.
  9. 9JavaScript String trimtrim removes whitespace from both ends of a string.
  10. 10JavaScript String ConcatenationConcatenation joins strings together into a longer one.
  11. 11JavaScript String ComparisonStrings compare character by character using their character codes.
  12. 12JavaScript String ImmutabilityStrings cannot be changed; every method returns a new one.