String Methods (JavaScript)

String methods are built-in functions for working with text, such as toUpperCase(), slice(), split(), and includes(). They return new strings without changing the original.

JavaScript

Strings in JavaScript are immutable, so methods return a new string rather than editing in place. Common tasks include changing case, finding text, replacing parts, and splitting into arrays.

Because strings act like read-only character arrays, you can also access individual characters by index.

Examples

JavaScript

const text = "Hello World";
console.log(text.toUpperCase());
console.log(text.includes("World"));
console.log(text.split(" "));

Output:

HELLO WORLD
true
[ 'Hello', 'World' ]

See also

Back to the Dictionary