@jonahsnider/util

    Function pull

    • Remove an element from an array.

      Time complexity: O(n)

      Space complexity: O(n)

      Type Parameters

      • T

      Parameters

      • array: T[]

        The array to remove an element from

      • element: T

        The element to remove

      Returns T[]

      The return value of Array.prototype.splice

      Array

      const array = [1, 2, 3];

      pull(array, 2); // [2]
      console.log(array); // [1, 3]

      pull(array, 2); // []
      console.log(array); // [1, 3]
    MMNEPVFCICPMFPCPTTAAATR