-1

I have the following objects:

var obj1 {
key1: "path"
};

var obj2 {
path: "done"
};

I want to get "done" (obj2.path) in the scope of obj1 key1. So the key "path" shall not be reached by obj2.path, but by obj1.key1.

Something like: obj2.(obj1.key1)?

i hope you can understand, sorry for my english :)

It's a PARODY
  • 53
  • 1
  • 3

1 Answers1

0

You can try using the [] notation to access property, which derived from obj1 key.

var obj1= {
key1: "path"
};

var obj2= {
path: "done"
};

console.log(obj2[obj1.key1]);
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307