I have a list of object, each object has a field name
:
let data = [{name: 'foo'}, {name: 'bar'}, {name: 'ipsum'}];
I would like to rename the name
field to title
. I tried following:
data.map(el => {el.title = el.name});
console.log(`${JSON.stringify(data)}`);
However, the result is that each object has an additional field title
instead of renaming name
field to title
. How can I rename the name
field to title
for each object in a list?