Lesson 20 / 38

String Methods

Everyday text operations, all non-mutating.

Everyday methods

Case, whitespace and search helpers cover most everyday text cleanup.

const s = "  Hello JS  ";
console.log(s.trim());
console.log(s.toUpperCase());
console.log(s.trim().includes("JS"));
console.log(s.replace("JS", "World"));

Slicing & splitting

split() turns text into an array; slice() extracts a substring by position.

const csv = "apple,banana,cherry";
console.log(csv.split(","));        // ['apple', 'banana', 'cherry']
console.log("Hello".slice(1, 4));   // "ell"

Strings are immutable

Every string method returns a new string — the original value never changes.