copyWithin
The copyWithin task copies a portion of an array within the same array. A specified part of an array is copied to a new location in the same array without modifying its size (length).
Potential use case
This task overwrites the original array by copying array elements to another position in the same array. Suppose you have a list of emails and you want to search for any duplicates in the list. You can specify where to start searching in the list (for example, 0 for the beginning) and where to end the search. You can also specify where in the email list the results will be copied to.
Properties
Example
In this example:
- The
arrvalue is["a","b","c","d"]. It has four elements. - The
targetindex is2. This means the destination begins at the2location in the index. Indexing starts at0and counts up from there. - The
startvariable of the search is0, which is the first location in the array being searched. - The
endvariable is2, indicating the search stops after the first two characters in the index and does not copy anything after that.

The result of this task copies the first two characters ("a" at index 0, "b" at index 1) and places that copy at index positions 2 and 3. The copiedArray that returns will be ["a","b","a","b"].
