简体   繁体   中英

Search value in associative array javascript

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)

when all this is done I want to check if any one in Object error still have value '1' or not. I have used the following but it does not seem to work..

    for ( i in error)
          if(error[i].value == '1')   -some code-  // this line gives error, not able to read value

what should be the correct method...??

只需删除.value

if(error[i] == '1'){...}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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