Skip to content

pop

The pop() function returns a new array without its last element. Tuples are updated exactly (via PopTuple).

Interactive example

Syntax

typescript
function pop<
	const GenericInput extends readonly unknown[]
>(
	input: GenericInput
): GenericInput extends AnyTuple ? PopTuple<GenericInput> : GenericInput

Parameters

  • input: Array from which to remove the last element.

Return value

A new array deprived of its last element. The other values are copied identically.

See also

  • push - Adds elements at the end of the array
  • shift - Removes the first element

Sources

Released under the MIT license.