0
I’m trying to get the value inside a given object using the key of another object: Ex:
I have the objects:
var obj1 = { id:'gh73f'}
var obj2 = {
gh73f : 123,
h39sg : 764,
c9wer : 921
}
I tried to:
var valor = obj2[obj1.id];
and
var valor = obj2[obj1[id]];
In none of the cases can I get the key value gh73f
of obj2
.
In firefox, the first way
var valor = obj2[obj1.id]
worked normally... For the second way to work, it should bevar valor = obj2[obj1['id']]
.– Felipe Avelar
The first form should work on any and all Javascript interpreters. You didn’t get it with any specific browser, or some engine like Node.js?
– Oralista de Sistemas
The first try really should work
– Tuyoshi Vinicius