
In cats a is at index 1 and s is at index 3, since the behaviour of substring() is to exclude the end index we got at. Inside the () (parenthesis) of substring() pass in two numerical arguments the start index to include and the end index to exclude. To use it pass substring after the string variable using a. The substring method will allow us to get a range of indexes from a string. To get one character from a string in JavaScript use (square brackets) containing the index of the character to get. In this tutorial, we will learn how to use these methods and what to do if you just need to get a single string character. JavaScript provides three methods for getting parts of a string each of which has slightly different behaviours substring(), substr() and slice(). As a result, we can get a range of indexes from a string.


Strings in JavaScript are iterable and behave somewhat like arrays as each character in the string has its own index number.
