Strings are immutable sequences of UTF-16 code units. Every string method returns a new string — the original never changes. Creating strings Single quotes, double quotes and template literals (backticks) all create strings. Template literals add ${expression} interpolation and multi-line text. Most-used methods Task Method Search includes(), startsWith(), endsWith(), indexOf() Extract slice(start, end), at(-1), substring() Transform toUpperCase(), toLowerCase(), trim(), padStart(), repeat() Split / join split(",") → array, array.join(", ") → string Replace replace() (first), replaceAll() (every match) Compare localeCompare() for correct alphabetical sorting Tagged templates A function placed before a template literal receives the raw string parts and values separately — used by…
Key Takeaways
Strings are immutable — methods always return a new string.
Template literals support interpolation, expressions and multi-line text.
Use replaceAll, padStart, at(-1) and localeCompare for common tasks.
Tagged templates let a function process template parts safely.
Emoji may count as 2 in .length; spread the string to count characters.