Skip to content

Instantly share code, notes, and snippets.

@nathakits
Created March 4, 2020 09:06
Show Gist options
  • Save nathakits/30ba0896dc0c89fe869565e191e56bb9 to your computer and use it in GitHub Desktop.
Save nathakits/30ba0896dc0c89fe869565e191e56bb9 to your computer and use it in GitHub Desktop.
Merge 2 array objects
const arr1 = [{attributes: "foobar"}]
const arr2 = [{html: "foobar"}]
const mergedArray = arr1.map((item,i)=>{
//merging two objects
return Object.assign({},item,arr2[i])
})
// mergedArray = [{attributes: "foobar", html: "foobar}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment