简体   繁体   English

Javascript修改数组对象的属性?

[英]Javascript modify array objects property?

So I have an array, where I am trying to update an objects property value, like so: 所以我有一个数组,我试图在其中更新对象属性值,如下所示:

        this.tasks[5].status = "complete";

   // Here is the object looks like when I log it:
    {"rowID":16,"task":"and more stuff","status":"incomplete","inlist":"Homework"}

Yet the above code does not change the value, it does nothing. 但是上面的代码并没有改变值,什么也没做。 Is my syntax wrong, or is there something else in my code causing this? 我的语法是否错误,还是我的代码中还有其他原因导致此错误?

It seems I can add properties to the object, but I cant modify existing ones. 似乎我可以向该对象添加属性,但不能修改现有属性。 I also can delete the object, but cant delete a property from it. 我也可以删除对象,但是不能从中删除属性。

Thanks 谢谢

It must be something else in your code. 它必须是代码中的其他内容。 Here are two pics of your setup working in both Chrome and IE9. 这是您在Chrome和IE9中均可使用的设置的两张图片。

Chrome Console Chrome控制台

IE9 Console IE9控制台

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM