Options
All
  • Public
  • Public/Protected
  • All
Menu

Module slice

Index

References

Functions Array

References

Renames and re-exports __type

Array Functions

  • slice<T>(array: ArrayLike<T>, start?: number, end?: number): T[]
  • Creates a slice of array from start up to, but not including, end.

    Note: This method is used instead of Array#slice to ensure dense arrays are returned.

    since

    5.6.0

    example
    var array = [1, 2, 3, 4]

    slice(array, 2)
    // => [3, 4]

    Type parameters

    • T

    Parameters

    • array: ArrayLike<T>

      The array to slice.

    • Optional start: number

      The start position. A negative index will be treated as an offset from the end.

    • Optional end: number

      The end position. A negative index will be treated as an offset from the end.

    Returns T[]

    Returns the slice of array.