JavaScript array.copyWithin() Function

JavaScript Logo

array.copyWithin() – Copies part of the array to another location within the same array, without changing its length.

๐Ÿ‘‰ Syntax

array.copyWithin(target, start = 0, end = array.length);

๐Ÿงช Example

[1,2,3,4].copyWithin(1,0,2); // [1,1,2,4]

Comments