Usage:
str.substring (start, end)
"String Literal".substring(start, end)
where "start" indicates the starting position of the string to be intercepted, and the index starts from 0 Count from the beginning.
"end" indicates the end position of the string to be intercepted, and the index starts from 0.
The substring() function method in JavaScript will return a string containing the substring from start to the end (excluding end).
The substring() function method in JavaScript uses the smaller value of start and end as the starting point of the substring. For example, strvar.substring(0, 3) and strvar.substring(3, 0) will return the same substring. If start or end is NaN or negative, replace it with 0. The length of the substring is equal to the absolute value of the difference between start and end. For example, the length of the substring returned by strvar.substring(0, 3) and strvar.substring(3, 0) is 3.
The following example demonstrates the use of the substring function method in JavaScript:
]