Tweakr
    Preparing search index...

    Function dropRight

    • Creates a slice of an array with n elements dropped from the end.

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to process.

      • n: number = 1

        The number of elements to drop from the end. Defaults to 1.

      Returns T[]

      A new array excluding the dropped elements from the end.

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

      dropRight([1, 2, 3]);
      // → [1, 2]

      1.0.0