[英]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.