substr() method extracts a part of a string.
substr() method begins at a specified position, and returns a specified number of characters.
syntax ↴
substr(start, length) ↴
start The index of the first character to include in the returned substring.
length (optional). The number of characters to extract.
substr() method does not change the original string.
substr() is deprecated and is no longer recommended; use substring() or slice() methods.
To extract characters from the end of the string, use a negative start position.
If start position is greater than or equal to the string length, an empty string "" is returned.
myString.substr(start)
myString.substr(start, length)