{ id: 34343,
unit_id: 1,
name: 'Small',
quantity: 40 },
'2':
{ id: 434,
unit_id: 2,
name: 'Medium',
quantity: 60 },
'3':
{ id: 1351,
unit_id: 3,
name: 'Large',
quantity: 90 }
}
I want each sub-object's unit_id (which is also same as its key ) and key
Iteration is usually done with arrays, you should consider that
Object.keys(that).map(key => { return { id: that[key].unit_id, name: that[key].name } }) or Object.keys(that).map(key => { return {id: key, name: that[key].name} }) if key == that[key].unit_id
how did you obtain this abomination?
Обсуждают сегодня