Substring vs Substr | Javascript

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)

References: here and here

One Response

Leave a Reply

Your email address will not be published. Required fields are marked *