hd-utils
Version:
A handy utils for modern JS developers
7 lines (6 loc) • 307 B
TypeScript
/**
* @description Creates a new array by replacing the element at a specified index with a given value, and returns the new modified array.
* @example
* replaceAtIndex([1, 2, 3, 4, 5], 2, 10) // [1, 2, 10, 4, 5];
*/
export default function replaceAtIndex<T>(arr: T[], index: number, newValue: T): T[];