Skip to content

Instantly share code, notes, and snippets.

@jamilservicos
Created March 11, 2017 11:29
Show Gist options
  • Save jamilservicos/3b84498c92cd8e1fa0f9b335770dc24b to your computer and use it in GitHub Desktop.
Save jamilservicos/3b84498c92cd8e1fa0f9b335770dc24b to your computer and use it in GitHub Desktop.
update array from other array
const data = {};
data.final = [
{ "id": 0, "name": "Fleming James" },
{ "id": 1, "name": "Everett Johnson" },
{ "id": 2, "name": "Brock Owens" }
];
data.update = [
{ "id": 0, "name": "Catherine Cooley" },
{ "id": 1, "name": "Mavis Grant" },
{ "id": 2, "name": "Brock Owens" }
];
for (let i = 0; i < Object.keys(data.update).length; i++) {
data.final[Object.keys(data.update)[i]] = data.update[Object.keys(data.update)[i]];
}
console.log(data.final);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment