Skip to content

Instantly share code, notes, and snippets.

@mknparreira
Last active August 12, 2021 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mknparreira/ab8287ce97a517827a63dfe07f3070ca to your computer and use it in GitHub Desktop.
Save mknparreira/ab8287ce97a517827a63dfe07f3070ca to your computer and use it in GitHub Desktop.
Javascript | If you want to remove one object using only the id property

If you want to remove one object using only the id property

## I need to replace objects in arr1 with items from arr2 with same id


const apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];

var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37);

// Remove object
apps.splice(removeIndex, 1);