Javascript: Objects and properties -


i have 2 objects

obj1 = {}; obj1[11].id = 123; obj1[11].lnkid = 111; ... obj1[99].id = 321; obj1[99].lnkid = 999; 

and

obj2 = {}; obj2[111].id = 111; obj2[111].type = 'permit'; ... obj2[999].id = 999; obj2[999].type = 'deny'; 

how can id property of object obj1 or object obj1[i], if need these steps:

  • i need compare value of property obj2[i].type (for example: if(obj2[i].type=='permit'){...})
  • if compare success, id of current object (it obj2[i].id equal 111)
  • and want find , object obj1 has property lnkid equal obj2[i].id (obj1[11].lnkid == 111).

after last step want var curr_obj = obj1[11]; var curr_id = curr_obj.id; //now curr_id value must 123

but don't know how find , object obj1 @ last step.

you can go throught obj1 objects , make compare obj2 id?

like

obj2id = findedid;  var = -1; while (++i < obj1.length) {   if (obj1[i].lnkid == obj2id)   {      // obj1   } } 

is looking for?


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -