Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
.substr() method returns a portion of a string specified by a starting position and length.
baseStringis the string whose substring is being returned.
posis the zero-based starting position of the substring. An exception is thrown if
posis greater than
lenis the number of characters to return in the substring. If
lenis greater than the number of characters after
pos, the whole remainder of the string is returned.
The following example prints out a section of a longer string.