JavaScript Array copyWithin()
JavaScript Array copyWithin()
The copyWithin() method is used to copy array elements to another position in the array. This will overwrite the existing values. We cannot add items in an array with it.
Syntax:-
Its syntax is:- array.copyWithin(target, start, end)
Return:-
It returns an array.
Further Explanation:-
Parameter | Description |
target | Required. The index position to copy the elements too. |
start | Optional. The start index position. Default is 0. |
end | Optional. The end index position. Default is the array length. |