copy array code example
Example 1: javascript copy an array
let arr =["a","b","c"];
const copy = [...arr];
const copy = Array.from(arr);
Example 2: copy array javascript
const sheeps = ['Apple', 'Banana', 'Juice'];
const cloneSheeps = sheeps.slice();
const cloneSheepsES6 = [...sheeps];
Example 3: java copy array
int[] src = {1,2,3,4,5};
int[] dst = Arrays.copyOf(src, src.length);
int[] dst2 = new int[src.length];
for(int i = 0; i < src.length; i++){
dst2[i] = src[i];
}
Example 4: how to make a copy of an array java
int a[] = {1, 8, 3};
int b[] = a.clone();
Example 5: java copy array
int[] a = {1, 2, 3};
int[] b = a.clone();
Example 6: java copy array
int[] a = {1,2,3,4,5};
int[] b = Arrays.copyOf(a, a.length);