Tweakr
    Preparing search index...

    Function slice

    • Creates a shallow copy of a portion of an array from start up to, but not including, end.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to slice.

      • start: number = 0

        The index to start extraction. Defaults to 0.

      • Optionalend: number

        The index before which to end extraction. If omitted, extracts through the end of the array.

      Returns T[]

      A new array containing the extracted elements.

      slice([1, 2, 3, 4], 1, 3);
      // → [2, 3]

      slice(["a", "b", "c"]);
      // → ["a", "b", "c"]

      1.0.0