简体   繁体   中英

Javascript accessing multidimensional Array without knowing all keys

I have a little experience in Javascript and usually I found solution to my problems just by searching here or with Google But this time, I feel that I took the wrong path

I have build an Object (multidimensional associative array) like this : state["a"]["b"]["c"] = "idle";

If I know "a" and "c" but not "b", can I change the value "idle" , without looping through each keys ? taking into account that "c" is unique in the whole object

Something like : state["a"][*]["c"] = "busy";

Thanks in advance for your help

如前所述,如果“ c”仅存在于一个位置,那么您将需要遍历第二维中的项,以查找具有索引为“ c”的第三维的项。

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