substring
The substring() method returns a substring between two indexes without modifying the original string.
Interactive example
Syntax
Classic signature
typescript
function substring<
GenericInput extends string
>(
input: GenericInput,
start: number,
end?: number
): stringCurried signature
typescript
function substring<
GenericInput extends string
>(
start: number,
end?: number
): (input: GenericInput) => stringParameters
input: The string to extract from.start: The index of the first character to include in the returned substring.end(optional): The index of the first character to exclude from the returned substring. If omitted, extracts to the end of the string.
Return value
A new string containing the specified section of the original string.
See also
slice- Extracts a section of a string with negative index supportcharAt- Returns the character at an indexindexOf- Finds the index of a substring
