Might be a stupid question, but why does map mutate array of objects.
var obj = {
items: [{
value: 1,
selected: true
}, {
value: 2,
selected: false
}]
};
var items = obj.items.map(i => {
if (i.value === 2) i.selected = true;
return i;
});
console.log(obj);
See Question&Answers more detail:os