array/extractByIndices

Extracts values from an array by their indices.

Source:

Methods

(static) extractByIndices(sourceopt, indicesopt) → {array}

Source:
Example
import { extractByIndices } from '@untemps/utils/array/extractByIndices'

const source = ['foo', 'bar', 'gag', 'pol', 'zux']
const indices = [1, 3]
extractByIndices(source, indices) // ['bar', 'pol']
Parameters:
Name Type Attributes Description
source array <optional>

The source array from which extract the values.

indices array <optional>

An array of indices.

Returns:

A new array containing the values at the specified indices only.

Type
array