更新现有的键值对会抛出<Object>没有方法'push'错误
Updating existing key value pair throws <Object> has no method 'push' error
我想用一个新的键值更新一个现有的JavaScript对象,也更新一个现有的值,像这样
$.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)
我的对象看起来像这样。
[
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...}
]
当前console.log输出如下错误:
Uncaught TypeError: Object #<Object> has no method 'push'
有谁能帮我弄明白这个吗? 您可以使用:
$.each(eventsData, function () {
if (this.ID == "eb_0") {
this.author_name = "John Seeds"; //new key value pair to be added.
this.title = newTitle_var; //to be updated
}
});
相关文章:
- Android/Javascript:Uncaught TypeError Object[Object]没有方法'
- angular ui下拉切换[object object]没有方法父级
- jqxGrid失败并出现错误“;Object[Object Object]没有方法'jqGrid'&”;
- 未捕获的类型错误:Object[Object Object]没有方法'fancybox'
- javascript中的Object.create方法
- jQuery令牌输入轨道获取错误Uncaught TypeError:Object[Object Object]没有方法
- 为什么dijit.form.Select有方法setStore(),而dijit.fform.FilteringSele
- 重写JavaScript中的Object.create方法
- 未捕获的类型错误:Object[Object Object]没有方法'滑块'
- jquery autocomplete组合框错误:未捕获类型错误:Object[Object Object]没有方法
- JQuery Object[Object Object]没有方法'滑块'当尝试使用滑块演示时
- jquery Object 没有方法 'xyz'
- Javascript TypeError: Object 没有方法
- Object.Prototype 方法和 IIFE(立即调用的函数表达式)中的“use strict”
- 使用 $().trigger() 并获取 TypeError: Object [object Object] 没有方法“
- SAPUI5 setTimeout() --> Object 没有方法
- 创建一个具有 3 个方法的 JavaScript 对象抛出 Object 没有方法
- Jquery:Uncatch TypeError:Object #
- Azure 节点.js脚本:TypeError:Object #
没有方法“toQueryObject” - jQuery uncatch TypeError Object 没有方法