use the substr method to extract a substring based on a starting index and a length:
Note that both slice and substr return a new string and do not modify the original string. Also note that both methods take optional arguments that allow you to omit the end index or the length of the substring. If you omit the end index or the length, the substring will include all characters from the starting index to the end of the string. If you pass negative numbers as arguments, they will be treated as offsets from the end of the string.
This code sets the myString variable to a string and sets the mySubstring variable to a slice of the string from index 0 (inclusive) to index 5 (exclusive). It then logs the substring to the console.