slice, substring, substr
Extracting parts of a string.
Examples
Using slice()
Extracting a substring from index 7 to 12.
let text = "Apple, Banana, Kiwi";
let part = text.slice(7, 13);
console.log(part); // BananaNegative Slice
Slicing from the end of the string.
let text = "Apple, Banana, Kiwi";
let part = text.slice(-12, -6);
console.log(part); // BananaTest Your Knowledge
JavaScript Quiz
No quiz available for this topic yet.