I have a very large Javascript Object, with a section that is blank, ready for me to dynamically add data to it. For the purpose of this question, I have removed unnecessary parts of my object.
This is my object:
var simplemaps_worldmap_mapdata = {
locations:{
}
}
This is my attempt to insert data into the object:
var mainObj = simplemaps_worldmap_mapdata;
var newObj = [];
newObj.push({
name: 'newName',
lat: 'newLat',
lng: 'newLong',
color: 'newColor',
description: 'newDesc',
url: 'newUrl',
size: 'newSize',
type: 'newType',
opacity: 'newOpacity'
});
mainObj.locations.push(newObj);
Why can't I dynamically add data to my object?
EDIT:
This is an example of how locations should look with one entry:
locations:{
0: {
name: 'newName',
lat: 'newLat',
lng: 'newLong',
color: 'newColor',
description: 'newDesc',
url: 'newUrl',
size: 'newSize',
type: 'newType',
opacity: 'newOpacity'
},
},
pushis a method in array, not in object