copyWithin() method copies array elements to another position in the same array and returns this array without modifying its length.
syntax ↴
copyWithin(target, start, end) ↴
target The index (position) to copy the elements to.
start (optional). The start index (position). Default is 0.
end (optional). The end index (position). Default is the array length.
Negative index counts back from the end of the array.
If end implies a position before or at the position that start implies, nothing is copied.
copyWithin() method overwrites the existing values.
copyWithin() method does not add items to the array.
myArray.copyWithin(target, start)
myArray.copyWithin(target, start, end)