Function pullAt

  • Removes elements from array corresponding to indexes and returns an array of removed elements.

    Note: Unlike at, this method mutates array.

    Type Parameters

    • T = any

    Parameters

    • array: T[]

      The array to modify.

    • Rest ...indexes: (string | number)[]

      The indexes of elements to remove.

      Rest

    Returns T[]

    Returns the new array of removed elements.

    Since

    5.11.0

    See

    [[pull]], [[pullAll]], [[pullAllBy]], [[pullAllWith]], [[remove]], [[reject]]

    Example

    const array = ['a', 'b', 'c', 'd']
    const pulled = pullAt(array, [1, 3])

    console.log(array)
    // => ['a', 'c']

    console.log(pulled)
    // => ['b', 'd']