Loading...
Loading...
Text manipulation. Immutable sequences of characters.
Real programs store collections of data. Arrays hold ordered lists, objects hold named properties, and modern syntax like destructuring and spread make working with both concise. JSON connects JavaScript data to every API on the web.
Learn Strings in JavaScript — covering String Basics, Template Literals, String Methods, Immutability with interactive visual examples and step-by-step explanations.
Arrays and objects are how JavaScript represents real-world data — a list of products, a user profile, a configuration file. Understanding how to create, read, update, and iterate over these structures is essential for any project.
This module covers array methods like map and filter, object property access, destructuring assignment, the spread operator, and JSON — the format every REST API speaks. Visual memory diagrams show how references and copies behave so you avoid common mutation bugs.
Understanding strings is essential for every JavaScript developer. It shows up in frontend UI code, backend APIs, and framework internals — and getting it wrong leads to bugs that are hard to trace. This chapter builds intuition with visuals so the behavior sticks.
Three ways to create. All are immutable.
const a = "double quotes"; const b = 'single quotes'; const c = `template literal`;
Each character has a zero-based index. Strings are like read-only arrays of characters.
Interpolation, multi-line, and tagged templates.
const name = "World"; const greeting = `Hello, ${name}!`; // "Hello, World!"
Backtick strings allow embedded expressions with ${...}
Transform, search, and extract.
.toUpperCase()HELLO, WORLD!.toLowerCase()hello, world!.trim()Hello, World!.split(', ')["Hello","World!"].includes('World')true.replace('World', 'JS')Hello, JS!.slice(0, 5)Hello.length13Strings never change. Methods return new strings.
let str = "Hello"; str[0] = "J"; // ✗ silently fails str.toUpperCase(); // returns "HELLO" console.log(str); // still "Hello" // To change, reassign: str = "J" + str.slice(1); // "Jello"
Every string method creates a new string. The original is never modified.
Common questions about strings.