Skip to main content

substring

Returns the part of the string from the start index up to and excluding the end index.

const str = "Hello";

str.substring(1, 3); // "el"
str.substring(2, str.length); // "llo"

⚠️ The arguments get implicitly coerced to uint

Syntax

substring(start, end)

Returns

A new string containing the specified part of the given string.