There is an object A and B:

var A = { "test": "asd" }; var B = { "test": { "asd": true } }; 

How to find out the value in B-> test-> asd by the keys from object A, something like this:

 var x = B[A]; // нужно узнать какое значение хранит asd // true console.log(x); 

Is there an easy way? without cycles?

  • I'm not a father in js, but how about: console.log (B.test.asd)? - NeedHate
  • 2
    B.test [A.test] returns true - Jean-Claude
  • The depth of the keys and the names of the keys will not be known ... - bsbak
  • If the depth of the keys and the names of the keys are not known in advance, then you cannot do without dialing and recursion. - Stepan Kasyanenko
  • one
    @bsbak give more examples with different keys / values ​​and array depth - webDev_

0