附加到对象 - Appending to an object

问题:

I have an object that holds alerts and some information about them:我有一个包含警报和有关它们的信息的对象:

var alerts = { 
    1: { app: 'helloworld', message: 'message' },
    2: { app: 'helloagain', message: 'another message' }
}

In addition to this, I have a variable that says how many alerts there are, alertNo .除此之外,我还有一个变量来说明有多少警报, alertNo My question is, when I go to add a new alert, is there a way to append the alert onto the alerts object?我的问题是,当我添加新警报时,有没有办法将警报附加到alerts对象上?


解决方案:

参考一: https://en.stackoom.com/question/2aWC
参考二: https://stackoom.com/question/2aWC
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章