Skip to content

String

In one line

A string is a sequence of characters used to represent text, enclosed in single, double, or backtick quotes.

In simple words

A string is text — a sequence of zero or more characters. JavaScript strings are immutable: once created, their contents cannot be changed (though you can create new strings from them).

Strings can be written with single quotes ('hello'), double quotes ("hello"), or backticks (`hello). Backticks create template literals, which support multi-line text and ${expression}` interpolation.

Common string methods include slice, split, replace, toUpperCase, trim, includes, and indexOf. Strings are iterable — you can loop over their characters with for...of.

Example

javascript
const name = "Ada";
const greeting = `Hello, ${name}!`;
console.log(greeting);          // "Hello, Ada!"
console.log(name.toUpperCase()); // "ADA"
console.log(name.length);        // 3

Template literals interpolate expressions; strings have methods and a length property.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary