I have the following javascript code:
var eventItems = {
"addevent": { name: "Add New Event" },
"addtodo": { name: "Add New Todo" }
};
console.log(eventItems);
How can I create the eventItems object dynamically? I've tried this, and it doesn't work.
var eventItems = [];
eventItems.push({ "addevent": { name: "Add New Event" } });
eventItems.push({ "addtodo": { name: "Add New Todo" } });
console.log(eventItems);
I realize the first statement isn't an array, but I'm not sure of the syntax to add these 2 elements dynamically one at a time. Edited: modified question to clarify what I'm trying to do.