Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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));
Source by www.samanthaming.com #
 
PREVIOUS NEXT
Tagged: #javascript #copy #array
ADD COMMENT
Topic
Name
5+5 =