The substring() method extracts the characters from a string, between two specified indices, and returns the new sub string. This method extracts the characters in a string between “from” and “to”, not including “to” itself.
string.substring(from, to)
The substr() method extracts the characters from a string, beginning at “start” and through the specified number of character, and returns the new sub string.
string.substr(start,length)
One Response
substring() vs. substr() … I “love” such naming “confusions” 😉
What happens to both functions when “index out of rage” occurs?