The substring() method is represented by the following syntax:
start - It represents the position of the string from where the fetching starts.
end - It is optional. It represents the position up to which the string fetches.
Part of the string.
Let's see some simple examples of substring() method.
Let's see a simple example to print the part of the string.Test it Now
In this example, we will fetch single character from the string.Test it Now
In this example, we will provide only the starting index.Test it Now
In this example, we will not pass any parameter with the method. In such case, the method returns the complete string.Test it Now