substr() Vs. substring()

The JavaScript string is an object that represents a sequence of characters. The substr() method extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters. The substring() method returns the part of the string between the start and end indexes, or to the end of the string. Syntax
string.substr(start, length)
start: The position where to start the extraction, index starting from 0. length: The number of characters to extract (optional). example
var s = "JavaScript"; var st = s.substr(4, 6); alert(st);

The above code would return "Script".

Syntax
string.substring(start, end)
start: The position where to start the extraction, index starting from 0. end: The position (up to, but not including) where to end the extraction (optional). example
var s = "JavaScript"; var st = s.substr(4, 10); alert(st);

The above code would return "Script"

substr() Vs. substring()

The difference is in the second argument. The second argument to substring is the index to stop at (but not include), but the second argument to substr is the maximum length to return. Moreover, substr() accepts a negative starting position as an offset from the end of the string. substring() does not.