Text is one of the most fundamental data formats in software. In JavaScript, strings represent sequences of UTF-16 character codes. Understanding string indexing, length, and immutability is essential for building web interfaces.
JavaScript supports three different quotation delimiters for string literals:
\):If a string contains quotation marks inside it, escape them with a backslash \:
\n : Newline (line break)\t : Tab indentation\\ : Literal backslashStrings behave similarly to arrays: characters are indexed starting at 0:
To change a string, you must create and assign a brand new string:
Because strings are iterable, you can loop through their characters using a for loop or for...of:
let s = "Hello"; s[0] = "Y"; console.log(s);?msg?str.at(-1))?Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Loop Control: break, continue | Common String Methods |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.
Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.