I have an object:
var obj= {
hello:{
it:"ciao",
en:"hello"
}
}
Now the problem is that i can't access a value through obj.hello[lang]
, neither obj.hello.en
.
i have a string like 'hello.it' or 'hello.en' and I want to get something like obj[myString] that became obj.hello.en
I tried to split the string with .split('.')
, but i have to loop hard coded through the length result
How can i achieve this?