Array copy code example
Example 1: java array copy
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 2: copy array javascript
const sheeps = ['Apple', 'Banana', 'Juice'];
const cloneSheeps = sheeps.slice();
const cloneSheepsES6 = [...sheeps];
Example 3: java copy array
int[] a = {1,2,3,4,5};
int[] b = Arrays.copyOf(a, a.length);
Example 4: js array clone
let clone = [...myArray]
Example 5: javascript copy array
var numbers = [1,2,3,4,5];
var newNumbers = Object.assign([], numbers);
Example 6: javascript copy array
var fruit = ["apple", "banana", "fig"];
console.log(fruit);
var fruit2 = fruit.slice();
console.log(fruit2);
var fruit3 = fruit.slice(0,2);
console.log(fruit3);