Skip to content

isLastIndex ​

The isLastIndex() function indicates whether an index corresponds to the last element of an array. It is curried to fit easily into compositions or reductions.

Interactive example ​

Syntax ​

Classic signature ​

typescript
function isLastIndex<
  GenericInput extends readonly unknown[],
>(
  input: GenericInput,
  index: number,
): boolean

Curried signature ​

typescript
function isLastIndex<
  GenericInput extends readonly unknown[],
>(
  index: number,
): (input: GenericInput) => boolean

Parameters ​

  • input: Target array.
  • index: Index to test.

Return value ​

true if index points to the last element of the array, false otherwise.

See also ​

  • lastIndexOf - Gives the index of the last occurrence
  • length - Returns the size of an array
  • reduce - Reduces an array to one value

Released under the MIT license.