var array = [ {'a': '12', 'b':'10'}, {'a': '20', 'b':'22'} ];
var r = array.map( x => {
x.c = true;
return x
})
console.log(r)
Run code snippet
//[ { a: '12', b: '10', c: true }, { a: '20', b: '22', c: true } ]
const data = [{ name: 'dendi', age: 23 }, { name: 'dhani' }]
const result = data.filter((v, i) => {
if (!Object.keys(v).includes('age')) {
Object.defineProperty(v, 'age', {
value: 25,
writeable: true,
enumerable: true
})
}
return v
})