The substring() function returns a part of a given string.string substring(string, number, number[optional])A string (or, if the value passed in is not a string, its string-value), and two numbers: the starting position of the substring and, optionally, a length in characters. Counting begins not with 0, but with 1. A negative start is possible (begin at position 1, count backwards the specified start value, then forward until the specified length is reached). NaN as the start value will return an empty string. NaN or negative vaules for length will return an empty string. If no length is specified, the substring continues until the end of the original string. If the second and third values are not numbers, they are converted using the rules of the number() function.