附加到對象 - 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章