JavaScript · String Methods · Interactive

String Methods,
in the real world

All 32 String methods illustrated with real scenarios — form validators, URL slugs, receipt formatters, search engines.

example.js
// Real string problems, real methods
const input = "  Mankal@Fork.DEV  ";
input.trim();           // "Mankal@Fork.DEV"
input.toLowerCase();    // "mankal@fork.dev"
input.includes("@");   // true
// Build a URL slug
"Hello World!"
  .toLowerCase()
  .replace(/[^a-z0-9]+/g, "-")
  .replace(/-$/, "");  // "hello-world"

5 real-world scenarios

All methods at a glance

includes()startsWith()endsWith()indexOf()lastIndexOf()match()matchAll()search()
Transform
toLowerCase()toUpperCase()trim()trimStart()trimEnd()replace()replaceAll()
Extract
slice()substring()at()charAt()split()
Build
padStart()padEnd()repeat()concat()
View full reference →