I have an array declared which uses the Object.assign:
var obj = [{
id: 1,
value: 'abc'
}, {
id: 2,
value: 'xyz'
}];
console.log(Object.assign({}, obj));
it's getting transformed as,
{
'0': { id: 1, value: 'abc' },
'1': { id: 2, value: 'xyz' }
}
However I need to have this as, (here the 1 and 2 represents the id attribute of my object)
{
'1': {id: 1, value: 'abc'},
'2': {id: 2, value: 'xyz'}
}
I've tried few, but had no luck, Can someone shed some light?