Javascript substring() syntax :
String.substring( from [, to ] )
This Javascript substring() method extracts the characters from a string between "from" and "to ", not including "to" itself.
Some Notes about Javascript Substring() Method:
If 'from' equals 'to', it returns an empty string.
If 'to' is omitted, it extracts characters to the end of the string.
If either argument is less than 0 or is NaN, it is treated as if it were 0.
If either argument is greater than string’s length, either argument will use string’s length.
If from >to, then substring will swap those 2 arguments.
Example of Javascript substring() Method :-