spliceReplace
The spliceReplace() function replaces a portion of the array with a set of new values. It is an immutable shortcut to splice with deleteCount equal to the number of elements to insert.
Interactive example
Syntax
Classic signature
typescript
function spliceReplace<
GenericElement extends unknown
>(
input: readonly GenericElement[],
indexFrom: number,
elements: GenericElement[]
): GenericElement[]Curried signature
typescript
function spliceReplace<
GenericElement extends unknown
>(
indexFrom: number,
elements: GenericElement[]
): (input: readonly GenericElement[]) => GenericElement[]Parameters
input: Source array.indexFrom: Index of the first element replaced.elements: Replacement array that overwrites as many elements as its length.
Return value
A new array where the targeted portion is replaced by elements.
See also
spliceDelete- Removes values without inserting anyspliceInsert- Inserts without deleting
