2👍
✅
Just use bracket notation like so:
Obj1 = {"name":"John", "age":30, "car":null};
Obj2 = {"John":{"country":"america", "job":"Engineer"}}
Obj2[Obj1.name].country;
// or
Obj2[Obj1["name"]]["country"]
1👍
You can access object properties using the square bracket syntax.
object.property
is equal to object["property"]
.
For your example, you can do
console.log(Obj2[Obj1.name]);
Source:stackexchange.com