I am looking for a solution in jQuery / javascript to add an object to an objectArray.
In my object I have the object "objectArray
". Inside of this elment is a dynamic number of other objects.
How can I add i.e. this object:
{
"code": "7891",
"items": {
"attribute": "car",
}
To the object Array without overwritting the frist element? To get this:
"objectArray": [
{
"code": "1234",
"items": {
"attribute": "House",
}
},
{
"code": "7891",
"items": {
"attribute": "car",
}
},
],
I used the way with arrays and JSON.stringify() but this doesn't work well.