Home / Javascript Tips Generated By ChatGPT / Extracting a Portion of String with substring in Javascript Use substring() to get a part of a string between two indices. Source Code let text = "Hello, world!"; console.log(text.substring(0, 5)); // "Hello"