Duplicates an array or a string and adds and/or removes one or more values from it. NOTE: This is different from the traditional splice function because it doesn't modify the array, but rather it returns a modified duplicate.

This function is valid in v2.1.0 to v2.24.2. This function has been downloaded 40 times.


{Array|string} arrOrStr
The array or string to be duplicated and modified.
{number} start
The position at which to start modifying arrOrStr. If this number is negative the position will be calculated from the end of arrOrStr.
{number=} opt_length Optional, Default:Infinity
Indicates the amount of indices that should be removed from arrOrStr. If negative this will be used as if it were an index counting from the end of arrOrStr.
{Array|string=} opt_replacement Optional
If specified, this will be inserted at start. If arrOrStr is an array, this should be an array of the values to insert at start. If arrOrStr is a string, this should be the string to insert at start.


The modified duplicate of arrOrStr.

Required Functions

This function directly requires the following functions which are included automatically:

  • isArrayLike()
    Determines if an object is an array or at least array-like.
  • slice()
    Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.