javascript append to html object code example

Example 1: add a child html object to another html object in js

//Add child at end of object children list
parent.append(child);
//Add child at start of object children list
parent.insertBefore(child, list.childNodes[0]);

Example 2: javascript append to object

How about storing the alerts as records in an array instead of properties of a single object ?

var alerts = [ 
    {num : 1, app:'helloworld',message:'message'},
    {num : 2, app:'helloagain',message:'another message'} 
]
And then to add one, just use push:

alerts.push({num : 3, app:'helloagain_again',message:'yet another message'});

Example 3: javascript append to object

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