I need your help;
Assume I have an array of objects like this
{
'Name:'ABC',
'Code': 'BP'
}
Which the best way to add an incremental attribute to this array in typescript.
[{'Name':'ABC','Code':'BP','ID':0}, [{'Name':'ABD','Code':'DP','ID':1},…]
Thanks
Please try this:
arrayOfObjects.forEach((obj, index) => obj.ID = index)