What is a Substring?
A substring is a string that is a part of another string:
The substring( ) Method
Let’s have a look at the substring() method first. This technique just extracts a portion of the original string and replaces it with a new string. Two parameters are required by the substring method:
- startIndex: indicates where the substring begins.
- endIndex: represents the substring’s end point (optional)
Let’s look at an example of how to use it. Assume we have the following example string: