array creating a copy code example
Example 1: java copy array
int[] a = {1,2,3,4,5};
int[] b = Arrays.copyOf(a, a.length);
Example 2: javascript copy array
var numbers = [1,2,3,4,5];
var newNumbers = Object.assign([], numbers);
Example 3: javascript copy array
// this is for array with complex object
var countries = [
{name: 'USA', population: '300M'},
{name: 'China', population: '1.6B'}
];
var newCountries = JSON.parse(JSON.stringify(countries));