mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
586 B
586 B
at
Retrieves elements from an array at the specified indices.
Signature
function at<T>(arr: T[], indices: number[]): T[];
Parameters
arr
(T[]
): The array to retrieve elements from.indices
(number[]
): An array of indices specifying the positions of elements to retrieve.
Returns
(T[]
): A new array containing the elements at the specified indices.
Examples
import { at } from 'es-toolkit/array';
const numbers = [10, 20, 30, 40, 50];
const result = at(numbers, [1, 3, 4]);
console.log(result); // [20, 40, 50]