Skip to content

after ​

The after function returns all elements of an array or characters of a string after the specified index.

Syntax ​

typescript
after(string: string, index: number): string;
after<T>(array: T[], index: number): T[];

Parameters ​

NameTypeDescription
arrayT[] | stringSource array or string
indexnumberIndex after which elements are returned

Returns ​

TypeDescription
T[] | stringElements or characters after the index

Examples ​

typescript
after([1, 2, 3, 4], 1); // => [3, 4]
after("abcdef", 2); // => "def"

Notes ​

  • The index is zero-based.
  • Returns an empty array or string if the index is the last element.

References ​

Released under the MIT License.