Skip to content

shift ​

The shift() function removes the first character from a string and returns a new string.

Interactive example ​

Syntax ​

typescript
function shift<
	GenericInput extends string
>(
	input: GenericInput
): Shift<GenericInput>

Parameters ​

  • input: String from which to remove the first character.

Return value ​

A new string without its first character. Literal types are preserved when possible.

See also ​

  • pop - Removes the last character of a string
  • substring - Extracts part of a string between two indexes

Released under the MIT license.