Now with ES6 we have a very powerful spread operator (...Object) which can make this job very easy. It can be done as follows:
let alerts = {
1: { app: 'helloworld', message: 'message' },
2: { app: 'helloagain', message: 'another message' }
}
//now suppose you want to add another key called alertNo. with value 2 in the alerts object.
alerts = {
...alerts,
alertNo: 2
}
Thats it. It will add the key you want. Hope this helps!!