var obj = {}
obj.cats = {'name': 'Milo', 'age': 3} // first item
Object.assign(obj.cats, {'name': 'Simba', 'age': 2}) // add new item to obj.cats
console.log(obj) // result one item in obj.cats (Simba)
How can I add to the obj.cats here? All solutions I try they override cats
Wanted result:
obj {
cats : {
{'name': 'Milo', 'age': 3},
{'name': 'Simba', 'age': 2}
}
}