pullAt

array

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

Signature

pullAt<T>(array: T[], indexes: number[]): T[]

Parameters

NameTypeDescription
arrayT[]The array to modify
indexesnumber[]The indexes of elements to remove

Returns

T[] - Returns the new array of removed elements

Examples

Remove at indexes

import { pullAt } from 'dashlite'

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

Output:

['a', 'c'] ['b', 'd']

Notes

  • This method mutates array

Available since version 1.0.0