Let's say we have an array of object:
var obj = [{a: 1, b: 2, c: 3, d: 4, e: 5 },{a: 6, b: 7, c:
8, d: 9, e: 0 }];
and we want to delete key c,e from both of the objects.
How can it be done? One of the methods I found is:
['c', 'e'].forEach(e => delete obj[e]); //for object
Is there any other way so we don't have to use double for loop.
obj.map(({ c, e, ...rest }) => rest)would create a new array of new objects with those keys removed.['c', 'e']is actually not known at build, only runtime).