JavaScript String Manipulation Methods: substring vs substr vs slice

Cutting Up Strings in JavaScript Ever been confused about all the different ways to chop up strings in JavaScript? You’re not alone! I’ve spent more hours than I’d like to admit trying to remember which method does what. JavaScript gives us three main ways to grab parts of strings: substring(), substr(), and slice(). They might look similar at first glance, but they each behave a bit differently. The String-Chopping Trio: A Quick Look Before we dive into the nitty-gritty, here’s a cheat sheet I wish I had when I was learning: ...

June 20, 2025 · 4 min · 750 words