I'm trying to update an existing JavaScript object with a new key value and also update an existing value like so
$.each(eventsData, function() {
if (this.ID== "eb_0") {
this.push({
author_name: "John Seeds" //new key value pair to be added.
title: newTitle_var //to be updated
});
}
});
console.log(this.eventsData)
My Object looks something like this.
[
Object { ID="eb_0", title="DayY", Date=Date, more...},
Object { ID="eb_1", title="DayZ", Date=Date, more...},
Object { ID="eb_2", title="DayX", Date=Date, more...}
]
Currently console.log outputs the following error.
Uncaught TypeError: Object #<Object> has no method 'push'
Could anyone help me figure this out please?