javascript - Updating existing key value pair throws <Object> has no method 'push' error -
i'm trying update existing javascript object new key value , update existing value so
$.each(eventsdata, function() { if (this.id== "eb_0") { this.push({ author_name: "john seeds" //new key value pair added. title: newtitle_var //to updated }); } }); console.log(this.eventsdata)
my object looks 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 following error.
uncaught typeerror: object #<object> has no method 'push'
could me figure out please?
you use:
$.each(eventsdata, function () { if (this.id == "eb_0") { this.author_name = "john seeds"; //new key value pair added. this.title = newtitle_var; //to updated } });
Comments
Post a Comment