[英]Search value in associative array javascript
var error = new Object ({'1a':'1','1b':'1','2a':'1'}); // like this I have defined around 200 values
if (some condition is true)
error[id] = 0; // id is selected dynamically ( '1a' or '1b' or what ever)
完成所有这些操作后,我想检查“对象”错误中是否还有一个值为“ 1”。 我已经使用了以下内容,但它似乎没有用..
for ( i in error)
if(error[i].value == '1') -some code- // this line gives error, not able to read value
什么是正确的方法...?
只需删除.value
:
if(error[i] == '1'){...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.