Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

replace object in array javascript

var item = {...}
var items = [{id:2}, {id:2}, {id:2}];

var foundIndex = items.findIndex(x => x.id == item.id);
items[foundIndex] = item;
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #replace #object #array #javascript
ADD COMMENT
Topic
Name
1+8 =