This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.

Smartphone icons created by Freepik - Flaticon

JavaScript String Methods

The substr() method extract a part of a string and returns the extracted parts in a new string:

let str = "Apple, Banana, Kiwi";
document.getElementById("demo").innerHTML = str.substr(7,6);

The substr gives a start position and the length, e.g substr(7,6). The "7" is the start position and the "6" is the length of the selection. If a length is not given, the selection is to the end of the string.