Function removeInPlace

  • Type Parameters

    • T

    Parameters

    • arr: T[]
    • predicate: (item: T) => boolean

    Returns false | T[]

    Remove an item from an array.

    Mutates the array

    const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
    const success = removeInPlace(arr, i => i === 5) // => [1, 2, 3, 4, 6, 7, 8, 9]
    success // => 5